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
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>
-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
-rw-r--r--kde-frameworks/kio/kio-5.82.0-r1.ebuild110
5 files changed, 354 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 00000000000..08d72d754d7
--- /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 00000000000..bf3ff50802f
--- /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 00000000000..a9c55e1f7f2
--- /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 00000000000..9e59a0eb16e
--- /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
+
diff --git a/kde-frameworks/kio/kio-5.82.0-r1.ebuild b/kde-frameworks/kio/kio-5.82.0-r1.ebuild
new file mode 100644
index 00000000000..297ae2bbe4a
--- /dev/null
+++ b/kde-frameworks/kio/kio-5.82.0-r1.ebuild
@@ -0,0 +1,110 @@
+# Copyright 1999-2021 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+ECM_DESIGNERPLUGIN="true"
+ECM_TEST="forceoptional"
+PVCUT=$(ver_cut 1-2)
+QTMIN=5.15.2
+VIRTUALX_REQUIRED="test"
+inherit ecm kde.org xdg-utils
+
+DESCRIPTION="Framework providing transparent file and data management"
+
+LICENSE="LGPL-2+"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~x86"
+IUSE="acl +handbook kerberos +kwallet X"
+
+# tests hang
+RESTRICT+=" test"
+
+RDEPEND="
+ dev-libs/libxml2
+ dev-libs/libxslt
+ >=dev-qt/qtdbus-${QTMIN}:5
+ >=dev-qt/qtdeclarative-${QTMIN}:5
+ >=dev-qt/qtgui-${QTMIN}:5
+ >=dev-qt/qtnetwork-${QTMIN}:5[ssl]
+ >=dev-qt/qtwidgets-${QTMIN}:5
+ >=dev-qt/qtxml-${QTMIN}:5
+ =kde-frameworks/kauth-${PVCUT}*:5
+ =kde-frameworks/karchive-${PVCUT}*:5
+ =kde-frameworks/kbookmarks-${PVCUT}*:5
+ =kde-frameworks/kcodecs-${PVCUT}*:5
+ =kde-frameworks/kcompletion-${PVCUT}*:5
+ =kde-frameworks/kconfig-${PVCUT}*:5
+ =kde-frameworks/kconfigwidgets-${PVCUT}*:5
+ =kde-frameworks/kcoreaddons-${PVCUT}*:5
+ =kde-frameworks/kcrash-${PVCUT}*:5
+ =kde-frameworks/kdbusaddons-${PVCUT}*:5
+ =kde-frameworks/kguiaddons-${PVCUT}*:5
+ =kde-frameworks/ki18n-${PVCUT}*:5
+ =kde-frameworks/kiconthemes-${PVCUT}*:5
+ =kde-frameworks/kitemviews-${PVCUT}*:5
+ =kde-frameworks/kjobwidgets-${PVCUT}*:5
+ =kde-frameworks/knotifications-${PVCUT}*:5
+ =kde-frameworks/kservice-${PVCUT}*:5
+ =kde-frameworks/ktextwidgets-${PVCUT}*:5
+ =kde-frameworks/kwidgetsaddons-${PVCUT}*:5
+ =kde-frameworks/kwindowsystem-${PVCUT}*:5
+ =kde-frameworks/kxmlgui-${PVCUT}*:5
+ =kde-frameworks/solid-${PVCUT}*:5
+ acl? (
+ sys-apps/attr
+ virtual/acl
+ )
+ handbook? ( =kde-frameworks/kdoctools-${PVCUT}*:5 )
+ kerberos? ( virtual/krb5 )
+ kwallet? ( =kde-frameworks/kwallet-${PVCUT}*:5 )
+ X? ( >=dev-qt/qtx11extras-${QTMIN}:5 )
+"
+DEPEND="${RDEPEND}
+ >=dev-qt/qtconcurrent-${QTMIN}:5
+ test? ( sys-libs/zlib )
+ X? (
+ x11-base/xorg-proto
+ x11-libs/libX11
+ x11-libs/libXrender
+ )
+"
+PDEPEND="
+ >=kde-frameworks/kded-${PVCUT}:5
+"
+
+PATCHES=(
+ # pending https://invent.kde.org/frameworks/kio/-/merge_requests/426
+ "${FILESDIR}"/${PN}-5.81.0-fix-qtconcurrent-private-link.patch # bug 784971
+ # upstream backport request - see also KDE-bug 398908
+ "${FILESDIR}"/${P}-MimeTypeFinderJob-memleak-{1,2,3,4}.patch
+ # git master/KIO 5.83:
+ "${FILESDIR}"/${P}-no-useragent-kcm.patch
+ "${FILESDIR}"/${P}-no-cache-kcm.patch
+)
+
+src_prepare() {
+ ecm_src_prepare
+ rm -rf po/*/docs/kcontrol5/{cache,useragent} || die # superfluous docs
+}
+
+src_configure() {
+ local mycmakeargs=(
+ $(cmake_use_find_package acl ACL)
+ $(cmake_use_find_package handbook KF5DocTools)
+ $(cmake_use_find_package kerberos GSSAPI)
+ $(cmake_use_find_package kwallet KF5Wallet)
+ $(cmake_use_find_package X X11)
+ )
+
+ ecm_src_configure
+}
+
+pkg_postinst() {
+ ecm_pkg_postinst
+ xdg_desktop_database_update
+}
+
+pkg_postrm() {
+ ecm_pkg_postrm
+ xdg_desktop_database_update
+}