From 0640e8a754f7fc20e397b3a722bc0b7dc4ff0755 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Fri, 11 Feb 2022 23:24:46 +0100 Subject: [PATCH] path_max.diff: replace with upstream commit backport upstream commit 7c54988b1b3b9eb4d2f3650c1ba5ffe97673ca92 --- debian/changelog | 3 ++ debian/patches/path_max.diff | 21 --------- debian/patches/series | 2 +- ...Avoid-a-stack-buffer-when-not-needed.patch | 47 +++++++++++++++++++ 4 files changed, 51 insertions(+), 22 deletions(-) delete mode 100644 debian/patches/path_max.diff create mode 100644 debian/patches/upstream_Avoid-a-stack-buffer-when-not-needed.patch diff --git a/debian/changelog b/debian/changelog index f4d6bde..192f842 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,9 @@ qt6-base (6.2.2+dfsg-4) UNRELEASED; urgency=medium [ Pino Toscano ] * Backport upstream commit 06e7b5168e269f913f03ecb9d77fc82db4d9dfd6 to enable LFS on Hurd; patch upstream_Hurd-enable-XOPEN-largefile-APIs.patch. + * Replace patch path_max.diff with upstream commit + 7c54988b1b3b9eb4d2f3650c1ba5ffe97673ca92; patch + upstream_Avoid-a-stack-buffer-when-not-needed.patch. -- Debian Qt/KDE Maintainers Thu, 10 Feb 2022 07:33:31 +0100 diff --git a/debian/patches/path_max.diff b/debian/patches/path_max.diff deleted file mode 100644 index b9014fa..0000000 --- a/debian/patches/path_max.diff +++ /dev/null @@ -1,21 +0,0 @@ -Author: Pino Toscano -Description: Avoid unconditional PATH_MAX usage - Use a "safe" size in case PATH_MAX is not defined; in the end, this should not - be used, as a allocating realpath() will be used instead. -Forwarded: no -Last-Update: 2020-04-19 - ---- a/src/corelib/io/qfilesystemengine_unix.cpp -+++ b/src/corelib/io/qfilesystemengine_unix.cpp -@@ -689,7 +689,11 @@ QFileSystemEntry QFileSystemEngine::cano - Q_UNUSED(data); - return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); - #else -+#ifdef PATH_MAX - char stack_result[PATH_MAX+1]; -+#else -+ char stack_result[4096+1]; -+#endif - char *resolved_name = nullptr; - # if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) - // On some Android and macOS versions, realpath() will return a path even if diff --git a/debian/patches/series b/debian/patches/series index 3677fb2..8c0c8d8 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -5,7 +5,7 @@ upstream_QStorageInfo-limit-Linux-only-code-with-Q_OS_LINUX.patch upstream_CMake-add-support-for-GNU-Hurd.patch upstream_QProcess-Unix-fallback-on-_POSIX_PIPE_BUF-w-missing-.patch upstream_Hurd-enable-XOPEN-largefile-APIs.patch +upstream_Avoid-a-stack-buffer-when-not-needed.patch # Debian specific remove_privacy_breaches.diff -path_max.diff diff --git a/debian/patches/upstream_Avoid-a-stack-buffer-when-not-needed.patch b/debian/patches/upstream_Avoid-a-stack-buffer-when-not-needed.patch new file mode 100644 index 0000000..15c5b99 --- /dev/null +++ b/debian/patches/upstream_Avoid-a-stack-buffer-when-not-needed.patch @@ -0,0 +1,47 @@ +From 7c54988b1b3b9eb4d2f3650c1ba5ffe97673ca92 Mon Sep 17 00:00:00 2001 +From: Pino Toscano +Date: Thu, 10 Feb 2022 08:26:11 +0100 +Subject: [PATCH] Avoid a stack buffer when not needed + +Allocate a PATH_MAX-sized buffer on stack only in case we are not using +realpath(X, null), i.e. on platforms with older POSIX versions, macOS, +or Android. + +This fixes the build on platforms that do not have PATH_MAX (e.g. +GNU/Hurd), and it provides a minor optimization on realpath(X, null) +platforms. + +Change-Id: Icd92a1b15ec18c5eef8113408e9610dfac774101 +Reviewed-by: Thiago Macieira +--- + src/corelib/io/qfilesystemengine_unix.cpp | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp +index 6e8229daec..fb66d47d38 100644 +--- a/src/corelib/io/qfilesystemengine_unix.cpp ++++ b/src/corelib/io/qfilesystemengine_unix.cpp +@@ -686,7 +686,9 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, + Q_UNUSED(data); + return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath())); + #else ++# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L + char stack_result[PATH_MAX+1]; ++# endif + char *resolved_name = nullptr; + # if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) + // On some Android and macOS versions, realpath() will return a path even if +@@ -714,8 +716,10 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, + data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; + data.entryFlags |= QFileSystemMetaData::ExistsAttribute; + QString canonicalPath = QDir::cleanPath(QFile::decodeName(resolved_name)); ++# if defined(Q_OS_DARWIN) || defined(Q_OS_ANDROID) || _POSIX_VERSION < 200801L + if (resolved_name != stack_result) + free(resolved_name); ++# endif + return QFileSystemEntry(canonicalPath); + } else if (errno == ENOENT || errno == ENOTDIR) { // file doesn't exist + data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute; +-- +2.34.1 +