summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Sturmlechner <asturm@gentoo.org>2021-05-15 12:46:06 +0200
committerAndreas Sturmlechner <asturm@gentoo.org>2021-05-15 12:49:22 +0200
commitaace2cf1177ab92d31ede9aeb02118d409baa700 (patch)
tree8ee577c50da349096490a257f853784b7ee96153 /kde-frameworks/kio/files
parentdev-vcs/stgit: QA: drop ${D} from src_compile() (diff)
downloadgentoo-aace2cf1177ab92d31ede9aeb02118d409baa700.tar.gz
gentoo-aace2cf1177ab92d31ede9aeb02118d409baa700.tar.bz2
gentoo-aace2cf1177ab92d31ede9aeb02118d409baa700.zip
kde-frameworks/kio: Upstream backport request for memleak fix
See also: https://mail.kde.org/pipermail/distributions/2021-May/000998.html KDE-bug: https://bugs.kde.org/show_bug.cgi?id=398908 Package-Manager: Portage-3.0.18, Repoman-3.0.3 Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
Diffstat (limited to 'kde-frameworks/kio/files')
-rw-r--r--kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch69
-rw-r--r--kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch61
-rw-r--r--kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch52
-rw-r--r--kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch62
4 files changed, 244 insertions, 0 deletions
diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch
new file mode 100644
index 000000000000..08d72d754d70
--- /dev/null
+++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-1.patch
@@ -0,0 +1,69 @@
+From e79da836c34fce66231e396c7215314d0eba51b4 Mon Sep 17 00:00:00 2001
+From: Jonathan Marten <jjm@keelhaul.me.uk>
+Date: Sat, 8 May 2021 15:20:39 +0000
+Subject: [PATCH] MimeTypeFinderJob: Resolve symlinks for a local file
+
+---
+ autotests/mimetypefinderjobtest.cpp | 18 +++++++++++++++++-
+ src/core/mimetypefinderjob.cpp | 2 +-
+ 2 files changed, 18 insertions(+), 2 deletions(-)
+
+diff --git a/autotests/mimetypefinderjobtest.cpp b/autotests/mimetypefinderjobtest.cpp
+index 72296b9b8..f494ff3b6 100644
+--- a/autotests/mimetypefinderjobtest.cpp
++++ b/autotests/mimetypefinderjobtest.cpp
+@@ -48,6 +48,7 @@ void MimeTypeFinderJobTest::determineMimeType_data()
+ QTest::newRow("text_file_no_extension") << "text/plain" << "srcfile";
+ QTest::newRow("desktop_file") << "application/x-desktop" << "foo.desktop";
+ QTest::newRow("script") << "application/x-shellscript" << "srcfile.sh";
++ QTest::newRow("directory") << "inode/directory" << "srcdir";
+ /* clang-format on */
+ }
+
+@@ -60,7 +61,12 @@ void MimeTypeFinderJobTest::determineMimeType()
+ QTemporaryDir tempDir;
+ const QString srcDir = tempDir.path();
+ const QString srcFile = srcDir + QLatin1Char('/') + fileName;
+- createSrcFile(srcFile);
++ if (mimeType == "inode/directory") {
++ QVERIFY(QDir(srcDir).mkdir(fileName));
++ } else {
++ createSrcFile(srcFile);
++ }
++
+ QVERIFY(QFile::exists(srcFile));
+ const QUrl url = QUrl::fromLocalFile(srcFile);
+
+@@ -68,6 +74,16 @@ void MimeTypeFinderJobTest::determineMimeType()
+ KIO::MimeTypeFinderJob *job = new KIO::MimeTypeFinderJob(url, this);
+ QVERIFY2(job->exec(), qPrintable(job->errorString()));
+ QCOMPARE(job->mimeType(), mimeType);
++
++ // Check that the result is the same when accessing the source
++ // file through a symbolic link (bug #436708)
++ const QString srcLink = srcDir + QLatin1String("/link_") + fileName;
++ QVERIFY(QFile::link(srcFile, srcLink));
++ const QUrl linkUrl = QUrl::fromLocalFile(srcLink);
++
++ job = new KIO::MimeTypeFinderJob(linkUrl, this);
++ QVERIFY2(job->exec(), qPrintable(job->errorString()));
++ QCOMPARE(job->mimeType(), mimeType);
+ }
+
+ void MimeTypeFinderJobTest::invalidUrl()
+diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
+index f5e50cdc4..48fc8c289 100644
+--- a/src/core/mimetypefinderjob.cpp
++++ b/src/core/mimetypefinderjob.cpp
+@@ -122,7 +122,7 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
+ {
+ Q_ASSERT(m_mimeTypeName.isEmpty());
+
+- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic, KIO::HideProgressInfo);
++ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
+ if (!m_authPrompts) {
+ job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
+ }
+--
+GitLab
+
diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch
new file mode 100644
index 000000000000..bf3ff50802f6
--- /dev/null
+++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-2.patch
@@ -0,0 +1,61 @@
+From c748d6987252fafc296cde9351b289ef734cf861 Mon Sep 17 00:00:00 2001
+From: Ahmad Samir <a.samirh78@gmail.com>
+Date: Thu, 13 May 2021 23:03:57 +0200
+Subject: [PATCH] kio_file: pass the absolute path to
+ QMimeDatabase::mimeTypeForFile()
+
+Otherwise detecting the mime type based on the file content may fail and
+return application/octet-stream.
+
+And pass the whole url to createUDSEntry(), less QFile::decodeName/encodeName()
+in the middle is better and less error prone.
+
+Note that without this change a MimeTypeFinderJob could end up failing to
+find the mime type of a local file based on the file contents.
+---
+ src/ioslaves/file/file_unix.cpp | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp
+index 99d46c8f1..940e3cbc4 100644
+--- a/src/ioslaves/file/file_unix.cpp
++++ b/src/ioslaves/file/file_unix.cpp
+@@ -364,7 +364,7 @@ inline static time_t stat_mtime(QT_STATBUF &buf)
+ }
+ #endif
+
+-static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details)
++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QUrl &url)
+ {
+ assert(entry.count() == 0); // by contract :-)
+ int entries = 0;
+@@ -539,7 +539,7 @@ static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSE
+
+ if (details & KIO::StatMimeType) {
+ QMimeDatabase db;
+- entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(filename).name());
++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(url.toLocalFile()).name());
+ }
+
+ return true;
+@@ -1186,7 +1186,7 @@ void FileProtocol::listDir(const QUrl &url)
+ listEntry(entry);
+
+ } else {
+- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details)) {
++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) {
+ #if HAVE_SYS_XATTR_H
+ if (isNtfsHidden(filename)) {
+ bool ntfsHidden = true;
+@@ -1476,7 +1476,7 @@ void FileProtocol::stat(const QUrl &url)
+ const KIO::StatDetails details = getStatDetails();
+
+ UDSEntry entry;
+- if (!createUDSEntry(url.fileName(), _path, entry, details)) {
++ if (!createUDSEntry(url.fileName(), _path, entry, details, url)) {
+ error(KIO::ERR_DOES_NOT_EXIST, path);
+ return;
+ }
+--
+GitLab
+
diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch
new file mode 100644
index 000000000000..a9c55e1f7f24
--- /dev/null
+++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-3.patch
@@ -0,0 +1,52 @@
+From c19876052ecec18a87a82f5950e8909e22e895ba Mon Sep 17 00:00:00 2001
+From: Ahmad Samir <a.samirh78@gmail.com>
+Date: Thu, 13 May 2021 17:02:52 +0200
+Subject: [PATCH] MimeTypeFinderJob: the StatJob details should include the
+ mimetype
+
+Apparently we forgot to specify that we want the UDS_MIME_TYPE field in
+the statFile() method (both when it lived in OpenUrlJob and when it was moved
+to MimeTypeFinderJob). And now there is a dedicated StatJob flag, StatMimeType,
+that we can use.
+
+Not passing KIO::StatMimeType when creating the StatJob meant the code always
+used a get job to determine the mime type, which mean that e.g. opening an
+ISO file from Dolphin, which supposedly just needs to launch Ark, had the
+whole file read into memory, which means that opening a couple of ISO's and
+you're out of memory...
+
+Thanks to sitter for doing a big chunk of the investigative work in the bug
+report.
+
+CCBUG: 398908
+---
+ src/core/mimetypefinderjob.cpp | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/core/mimetypefinderjob.cpp b/src/core/mimetypefinderjob.cpp
+index 48fc8c289..baca58695 100644
+--- a/src/core/mimetypefinderjob.cpp
++++ b/src/core/mimetypefinderjob.cpp
+@@ -122,7 +122,9 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
+ {
+ Q_ASSERT(m_mimeTypeName.isEmpty());
+
+- KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, KIO::StatBasic | KIO::StatResolveSymlink, KIO::HideProgressInfo);
++ static constexpr auto statFlags = KIO::StatBasic | KIO::StatResolveSymlink | KIO::StatMimeType;
++
++ KIO::StatJob *job = KIO::statDetails(m_url, KIO::StatJob::SourceSide, statFlags, KIO::HideProgressInfo);
+ if (!m_authPrompts) {
+ job->addMetaData(QStringLiteral("no-auth-prompt"), QStringLiteral("true"));
+ }
+@@ -147,6 +149,8 @@ void KIO::MimeTypeFinderJobPrivate::statFile()
+
+ const KIO::UDSEntry entry = job->statResult();
+
++ qCDebug(KIO_CORE) << "UDSEntry from StatJob in MimeTypeFinderJob" << entry;
++
+ const QString localPath = entry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH);
+ if (!localPath.isEmpty()) {
+ m_url = QUrl::fromLocalFile(localPath);
+--
+GitLab
+
diff --git a/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch
new file mode 100644
index 000000000000..9e59a0eb16eb
--- /dev/null
+++ b/kde-frameworks/kio/files/kio-5.82.0-MimeTypeFinderJob-memleak-4.patch
@@ -0,0 +1,62 @@
+From 71484c97dee0c977a00f141123d8ccd9b93c2e96 Mon Sep 17 00:00:00 2001
+From: Ahmad Samir <a.samirh78@gmail.com>
+Date: Fri, 14 May 2021 21:19:31 +0200
+Subject: [PATCH] kio_file: fix how createUDSEntry() is called
+
+When calling createUDSEntry() from listDir(), we need to concatenate the full
+path to the item.
+
+This is an addendum to commit c748d6987252f.
+---
+ src/ioslaves/file/file_unix.cpp | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/src/ioslaves/file/file_unix.cpp b/src/ioslaves/file/file_unix.cpp
+index 940e3cbc4..3573c200e 100644
+--- a/src/ioslaves/file/file_unix.cpp
++++ b/src/ioslaves/file/file_unix.cpp
+@@ -364,7 +364,7 @@ inline static time_t stat_mtime(QT_STATBUF &buf)
+ }
+ #endif
+
+-static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QUrl &url)
++static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSEntry &entry, KIO::StatDetails details, const QString &fullPath)
+ {
+ assert(entry.count() == 0); // by contract :-)
+ int entries = 0;
+@@ -539,7 +539,7 @@ static bool createUDSEntry(const QString &filename, const QByteArray &path, UDSE
+
+ if (details & KIO::StatMimeType) {
+ QMimeDatabase db;
+- entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(url.toLocalFile()).name());
++ entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, db.mimeTypeForFile(fullPath).name());
+ }
+
+ return true;
+@@ -1186,7 +1186,13 @@ void FileProtocol::listDir(const QUrl &url)
+ listEntry(entry);
+
+ } else {
+- if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, url)) {
++ QString fullPath(path);
++ if (!fullPath.endsWith(QLatin1Char('/'))) {
++ fullPath += QLatin1Char('/');
++ }
++ fullPath += filename;
++
++ if (createUDSEntry(filename, QByteArray(ep->d_name), entry, details, fullPath)) {
+ #if HAVE_SYS_XATTR_H
+ if (isNtfsHidden(filename)) {
+ bool ntfsHidden = true;
+@@ -1476,7 +1482,7 @@ void FileProtocol::stat(const QUrl &url)
+ const KIO::StatDetails details = getStatDetails();
+
+ UDSEntry entry;
+- if (!createUDSEntry(url.fileName(), _path, entry, details, url)) {
++ if (!createUDSEntry(url.fileName(), _path, entry, details, path)) {
+ error(KIO::ERR_DOES_NOT_EXIST, path);
+ return;
+ }
+--
+GitLab
+