[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [calligra] krita/ui: Don't crash krita if the exiv parser throws an exception
From:       Boudewijn Rempt <boud () valdyas ! org>
Date:       2013-05-20 8:30:15
Message-ID: 20130520083015.41BA0A605B () git ! kde ! org
[Download RAW message or body]

Git commit 022cafbf59524050acf74d2a27ee75d33bae5a6e by Boudewijn Rempt.
Committed on 20/05/2013 at 10:29.
Pushed by rempt into branch 'master'.

Don't crash krita if the exiv parser throws an exception

BUG:320037

Turns out we don't do anything with the return value of KisExifIO::loadFrom,
but let's return false anyway when parsing fails.

M  +2    -0    krita/ui/CMakeLists.txt
M  +12   -1    krita/ui/kisexiv2/kis_exif_io.cpp

http://commits.kde.org/calligra/022cafbf59524050acf74d2a27ee75d33bae5a6e

diff --git a/krita/ui/CMakeLists.txt b/krita/ui/CMakeLists.txt
index 8485c20..d501e98 100644
--- a/krita/ui/CMakeLists.txt
+++ b/krita/ui/CMakeLists.txt
@@ -1,3 +1,5 @@
+add_definitions(${KDE4_ENABLE_EXCEPTIONS})
+
 include_directories( ${KOTEXT_INCLUDES}
     ${TEXTLAYOUT_INCLUDES}
     ${CMAKE_SOURCE_DIR}/libs/pigment/colorprofiles
diff --git a/krita/ui/kisexiv2/kis_exif_io.cpp b/krita/ui/kisexiv2/kis_exif_io.cpp
index 2f32a23..992baf1 100644
--- a/krita/ui/kisexiv2/kis_exif_io.cpp
+++ b/krita/ui/kisexiv2/kis_exif_io.cpp
@@ -511,7 +511,18 @@ bool KisExifIO::loadFrom(KisMetaData::Store* store, QIODevice* ioDevice) const
     exifData.load((const Exiv2::byte*)arr.data(), arr.size());
     byteOrder = exifData.byteOrder();
 #else
-    byteOrder = Exiv2::ExifParser::decode(exifData, (const Exiv2::byte*)arr.data(), arr.size());
+    try {
+        byteOrder = Exiv2::ExifParser::decode(exifData, (const Exiv2::byte*)arr.data(), arr.size());
+    }
+    catch (const std::exception& ex) {
+        qWarning() << "Received exception trying to parse exiv data" << ex.what();
+        return false;
+    }
+    catch (...) {
+        qDebug() << "Received unknown exception trying to parse exiv data";
+        return false;
+    }
+
 #endif
     dbgFile << "Byte order = " << byteOrder << ppVar(Exiv2::bigEndian) << ppVar(Exiv2::littleEndian);
     dbgFile << "There are" << exifData.count() << " entries in the exif section";
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic