[frameworks/kio] src/gui: KProcessRunner: Handle canonicalPath() returning bogus values
Kai Uwe Broulik <[email protected]> Wed, 5 Aug 2026 08:40:02 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit ab8ad639833119c44b1c3043e2282889908f844a by Kai Uwe Broulik.
Committed on 05/08/2026 at 08:25.
Pushed by broulik into branch 'master'.
KProcessRunner: Handle canonicalPath() returning bogus values
The underlying realpath() can fail in funny ways on special
file systems like /proc, returning bogus values like "."
which then will cause the application to fail.
M +4 -1 src/gui/kprocessrunner.cpp
https://invent.kde.org/frameworks/kio/-/commit/ab8ad639833119c44b1c3043e2282889908f844a
diff --git a/src/gui/kprocessrunner.cpp b/src/gui/kprocessrunner.cpp
index cbb290d0e3..97b6f0d20a 100644
--- a/src/gui/kprocessrunner.cpp
+++ b/src/gui/kprocessrunner.cpp
@@ -151,7 +151,10 @@ KProcessRunner *KProcessRunner::fromApplication(const KService::Ptr &service,
const QFileInfo fileInfo(urls.first().toLocalFile());
// canonicalPath returns "." despite documentation claiming to return an empty string.
if (fileInfo.exists()) {
- workingDir = fileInfo.canonicalPath();
+ // realpath() doesn't work properly in /proc and we can get bogus values.
+ if (const QString canonicalPath = fileInfo.canonicalPath(); QDir::isAbsolutePath(canonicalPath)) {
+ workingDir = canonicalPath;
+ }
}
}
instance->m_process->setWorkingDirectory(workingDir);