commit:     e5d5b6474794bf4cab01a184fc86b2d90529077f
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 18 09:33:41 2018 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sun Nov 18 09:36:54 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e5d5b647

kde-frameworks/kcoreaddons: Fix crash if XDG_CACHE_HOME is too small

KDE-bug: https://bugs.kde.org/show_bug.cgi?id=400610
Reported-by: Mike <bugs <AT> ubhofmann.de>
Package-Manager: Portage-2.3.51, Repoman-2.3.12
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 ...ddons-5.52.0-xdg_cache_home-nospace-crash.patch | 54 ++++++++++++++++++++++
 .../kcoreaddons/kcoreaddons-5.52.0-r1.ebuild       | 41 ++++++++++++++++
 2 files changed, 95 insertions(+)

diff --git 
a/kde-frameworks/kcoreaddons/files/kcoreaddons-5.52.0-xdg_cache_home-nospace-crash.patch
 
b/kde-frameworks/kcoreaddons/files/kcoreaddons-5.52.0-xdg_cache_home-nospace-crash.patch
new file mode 100644
index 00000000000..7b1a7965292
--- /dev/null
+++ 
b/kde-frameworks/kcoreaddons/files/kcoreaddons-5.52.0-xdg_cache_home-nospace-crash.patch
@@ -0,0 +1,54 @@
+From eb916c305a5cd8683e7e8f955740a7c810220e19 Mon Sep 17 00:00:00 2001
+From: Alexey Min <[email protected]>
+Date: Thu, 8 Nov 2018 00:28:30 +0300
+Subject: Fix crash if XDG_CACHE_HOME directory is too small or out of space
+
+Summary:
+Incorrect checking for error return code of posix_fallocate() causes function 
to think that everything is OK, while it is not, causing crash in some cases.
+
+BUG: 400610
+CCBUG: 339829
+
+Test Plan:
+good test plan provided in https://bugs.kde.org/show_bug.cgi?id=400610 . Works 
like a charm, tested in KDE Neon dev-ustable
+
+The reason for bug was that return value of posix_fallocate() was assumed to 
be negative on error, but in fact it is a positive integer. The check was `< 
0`, whi should be `!= 0`. ( 
http://man7.org/linux/man-pages/man3/posix_fallocate.3.html )
+
+With this fix applied test application does not crash, and the output in 
console widow is:
+```
+No space left on device. Check filesystem free space at your XDG_CACHE_HOME!
+The operating system is unable to promise 10547304 bytes for mapped cache, 
abandoning the cache for crash-safety.
+org.kde.kcoreaddons: Failed to establish shared memory mapping, will fallback 
to private memory -- memory usage will increase
+```
+
+Reviewers: dfaure, #frameworks, mpyne
+
+Reviewed By: dfaure
+
+Subscribers: cfeck, kde-frameworks-devel
+
+Tags: #frameworks
+
+Differential Revision: https://phabricator.kde.org/D16744
+---
+ src/lib/caching/kshareddatacache_p.h | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/src/lib/caching/kshareddatacache_p.h 
b/src/lib/caching/kshareddatacache_p.h
+index 625bc5d..c13275b 100644
+--- a/src/lib/caching/kshareddatacache_p.h
++++ b/src/lib/caching/kshareddatacache_p.h
+@@ -472,7 +472,10 @@ static bool ensureFileAllocated(int fd, size_t fileSize)
+         ;
+     }
+ 
+-    if (result < 0) {
++    if (result != 0) {
++        if (result == ENOSPC) {
++            qCritical() << "No space left on device. Check filesystem free 
space at your XDG_CACHE_HOME!";
++        }
+         qCritical() << "The operating system is unable to promise"
+                     << fileSize
+                     << "bytes for mapped cache, "
+-- 
+cgit v0.11.2

diff --git a/kde-frameworks/kcoreaddons/kcoreaddons-5.52.0-r1.ebuild 
b/kde-frameworks/kcoreaddons/kcoreaddons-5.52.0-r1.ebuild
new file mode 100644
index 00000000000..af442d38971
--- /dev/null
+++ b/kde-frameworks/kcoreaddons/kcoreaddons-5.52.0-r1.ebuild
@@ -0,0 +1,41 @@
+# Copyright 1999-2018 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+inherit kde5
+
+DESCRIPTION="Framework for solving common problems such as caching, 
randomisation, and more"
+LICENSE="LGPL-2+"
+KEYWORDS="~amd64 ~arm ~arm64 ~x86"
+IUSE="fam nls"
+
+RDEPEND="
+       $(add_qt_dep qtcore 'icu')
+       fam? ( virtual/fam )
+"
+DEPEND="${RDEPEND}
+       x11-misc/shared-mime-info
+       nls? ( $(add_qt_dep linguist-tools) )
+"
+
+PATCHES=( "${FILESDIR}/${P}-xdg_cache_home-nospace-crash.patch" )
+
+src_configure() {
+       local mycmakeargs=(
+               -D_KDE4_DEFAULT_HOME_POSTFIX=4
+               $(cmake-utils_use_find_package fam FAM)
+       )
+
+       kde5_src_configure
+}
+
+src_test() {
+       # bugs: 619656, 632398, 647414, 665682
+       local myctestargs=(
+               -j1
+               -E "(kautosavefiletest|kdirwatch_qfswatch_unittest|kformattest)"
+       )
+
+       kde5_src_test
+}

Reply via email to