summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-15 18:23:25 (GMT)
committerElvis Angelaccio <elvis.angelaccio@kde.org>2016-11-15 18:23:25 (GMT)
commit0b981c544e994175403504124a1e44ecfa144e33 (patch)
tree5d68c1e7368f7a898ebd180f5b0635fda88706e5
parent0e1653f48acd7df64c8d461235b93269aea69055 (diff)
Stop crashing when lsar's output is too big
lsar can generate huge json output when listing big solid rar archives. This will be fixed in lsar, but meanwhile we can catch a bad_alloc if we're using an affected version of lsar. BUG: 372210 FIXED-IN: 16.12.0 Differential Revision: D3350
-rw-r--r--autotests/plugins/cliunarchiverplugin/CMakeLists.txt3
-rw-r--r--plugins/cliunarchiverplugin/CMakeLists.txt3
-rw-r--r--plugins/cliunarchiverplugin/cliplugin.cpp10
3 files changed, 15 insertions, 1 deletions
diff --git a/autotests/plugins/cliunarchiverplugin/CMakeLists.txt b/autotests/plugins/cliunarchiverplugin/CMakeLists.txt
index a831936..5424354 100644
--- a/autotests/plugins/cliunarchiverplugin/CMakeLists.txt
+++ b/autotests/plugins/cliunarchiverplugin/CMakeLists.txt
@@ -12,3 +12,6 @@ ecm_add_test(
LINK_LIBRARIES testhelper kerfuffle Qt5::Test
TEST_NAME cliunarchivertest
NAME_PREFIX plugins-)
+
+# cliunarchiver plugin needs exceptions enabled
+kde_target_enable_exceptions(cliunarchivertest PRIVATE)
diff --git a/plugins/cliunarchiverplugin/CMakeLists.txt b/plugins/cliunarchiverplugin/CMakeLists.txt
index 9068856..df7a2b7 100644
--- a/plugins/cliunarchiverplugin/CMakeLists.txt
+++ b/plugins/cliunarchiverplugin/CMakeLists.txt
@@ -22,6 +22,9 @@ configure_file(
kerfuffle_add_plugin(kerfuffle_cliunarchiver ${kerfuffle_cliunarchiver_SRCS})
+# This plugin has a catch() block
+kde_target_enable_exceptions(kerfuffle_cliunarchiver PRIVATE)
+
set(SUPPORTED_ARK_MIMETYPES "${SUPPORTED_ARK_MIMETYPES}${SUPPORTED_CLIUNARCHIVER_MIMETYPES}"
PARENT_SCOPE)
set(INSTALLED_KERFUFFLE_PLUGINS "${INSTALLED_KERFUFFLE_PLUGINS}kerfuffle_cliunarchiver;" PARENT_SCOPE)
diff --git a/plugins/cliunarchiverplugin/cliplugin.cpp b/plugins/cliunarchiverplugin/cliplugin.cpp
index 50ba5de..59f8f8c 100644
--- a/plugins/cliunarchiverplugin/cliplugin.cpp
+++ b/plugins/cliunarchiverplugin/cliplugin.cpp
@@ -138,7 +138,15 @@ bool CliPlugin::handleLine(const QString& line)
{
// Collect the json output line by line.
if (m_operationMode == List) {
- m_jsonOutput += line + QLatin1Char('\n');
+ // #372210: lsar can generate huge JSONs for big archives.
+ // We can at least catch a bad_alloc here in order to not crash.
+ try {
+ m_jsonOutput += line + QLatin1Char('\n');
+ } catch (const std::bad_alloc&) {
+ m_jsonOutput.clear();
+ emit error(i18n("Not enough memory for loading the archive."));
+ return false;
+ }
}
if (m_operationMode == List) {