[digikam] [Bug 376898] New: Crash when scanning photo containing exif with empty Jis comment (Digikam::MetaEngine::getExifComment, QTextCodec::toUnicode)

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 376898] New: Crash when scanning photo containing exif with empty Jis comment (Digikam::MetaEngine::getExifComment, QTextCodec::toUnicode)

bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=376898

            Bug ID: 376898
           Summary: Crash when scanning photo containing exif with empty
                    Jis comment (Digikam::MetaEngine::getExifComment,
                    QTextCodec::toUnicode)
           Product: digikam
           Version: 5.5.0
          Platform: Archlinux Packages
                OS: Linux
            Status: UNCONFIRMED
          Severity: crash
          Priority: NOR
         Component: Metadata-Engine
          Assignee: [hidden email]
          Reporter: [hidden email]
  Target Milestone: ---

Application crashes when scanning a jpeg file with funky exif metadata.
When MetaEngine::Private::convertCommentValue() gets called for exif comment
encoded using "Jis" charset and comment contains "\000\000..." (empty string)
whole application segfaults.

Am using arch linux with:
extra/digikam 5.4.0-2
extra/qt5-base 5.8.0-5
extra/exiv2 0.25-3
extra/libkexiv2 16.12.2-1

Have also tried rebuilding digikam from git (master commit 1546044e48) and it
crashes with same stacktrace, below is stack trace and patch that avoided the
crash.


Thread 4 "Digikam::ScanCo" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffab5ef700 (LWP 20074)]
0x00007ffff427c3be in QTextCodec::toUnicode(char const*) const () from
/usr/lib/libQt5Core.so.5
(gdb) bt
#0  0x00007ffff427c3be in QTextCodec::toUnicode(char const*) const () at
/usr/lib/libQt5Core.so.5
#1  0x00007ffff65f1309 in  () at /usr/lib/libdigikamcore.so.5.5.0
#2  0x00007ffff6609409 in Digikam::MetaEngine::getExifComment() const () at
/usr/lib/libdigikamcore.so.5.5.0
#3  0x00007ffff663baaa in
Digikam::DMetadata::getImageComments(Digikam::DMetadataSettingsContainer
const&) const () at /usr/lib/libdigikamcore.so.5.5.0
#4  0x00007ffff3ccf6ac in Digikam::ImageScanner::scanImageComments() () at
/usr/lib/libdigikamdatabase.so.5.5.0
#5  0x00007ffff3cd1076 in
Digikam::ImageScanner::scanFile(Digikam::ImageScanner::ScanMode) () at
/usr/lib/libdigikamdatabase.so.5.5.0
#6  0x00007ffff3bfa86c in Digikam::CollectionScanner::scanNewFile(QFileInfo
const&, int) () at /usr/lib/libdigikamdatabase.so.5.5.0
#7  0x00007ffff3bfc446 in
Digikam::CollectionScanner::scanAlbum(Digikam::CollectionLocation const&,
QString const&) () at /usr/lib/libdigikamdatabase.so.5.5.0
#8  0x00007ffff3bfc376 in
Digikam::CollectionScanner::scanAlbum(Digikam::CollectionLocation const&,
QString const&) () at /usr/lib/libdigikamdatabase.so.5.5.0
#9  0x00007ffff3bfca79 in
Digikam::CollectionScanner::scanAlbumRoot(Digikam::CollectionLocation const&)
() at /usr/lib/libdigikamdatabase.so.5.5.0
#10 0x00007ffff3bfccbb in Digikam::CollectionScanner::completeScan() () at
/usr/lib/libdigikamdatabase.so.5.5.0
#11 0x00007ffff740c345 in Digikam::ScanController::run() () at
/usr/lib/libdigikamgui.so.5.5.0
#12 0x00007ffff40476d8 in  () at /usr/lib/libQt5Core.so.5
#13 0x00007fffedfaa454 in start_thread () at /usr/lib/libpthread.so.0
#14 0x00007ffff33457df in clone () at /usr/lib/libc.so.6



diff --git a/libs/dmetadata/metaengine_p.cpp b/libs/dmetadata/metaengine_p.cpp
index 2b44e06c21..1819c503ea 100644
--- a/libs/dmetadata/metaengine_p.cpp
+++ b/libs/dmetadata/metaengine_p.cpp
@@ -416,7 +416,8 @@ QString MetaEngine::Private::convertCommentValue(const
Exiv2::Exifdatum& exifDat
                else if (charset == "\"Jis\"")
                {
                        QTextCodec* const codec =
QTextCodec::codecForName("JIS7");
-                       return codec->toUnicode(comment.c_str());
+                       const char *tmp = comment.c_str();
+                       return *tmp ? codec->toUnicode(tmp) :
QStringLiteral("");
                }
                else if (charset == "\"Ascii\"")
                {

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 376898] Crash when scanning photo containing exif with empty Jis comment (Digikam::MetaEngine::getExifComment, QTextCodec::toUnicode) [patch]

bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=376898

[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Crash when scanning photo   |Crash when scanning photo
                   |containing exif with empty  |containing exif with empty
                   |Jis comment                 |Jis comment
                   |(Digikam::MetaEngine::getEx |(Digikam::MetaEngine::getEx
                   |ifComment,                  |ifComment,
                   |QTextCodec::toUnicode)      |QTextCodec::toUnicode)
                   |                            |[patch]
                 CC|                            |[hidden email]

--- Comment #1 from [hidden email] ---
Can you share an image with this kind of Exif::Jis comment ?

Gilles Caulier

--
You are receiving this mail because:
You are the assignee for the bug.
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 376898] Crash when scanning photo containing exif with empty Jis comment (Digikam::MetaEngine::getExifComment, QTextCodec::toUnicode) [patch]

bugzilla_noreply
In reply to this post by bugzilla_noreply
https://bugs.kde.org/show_bug.cgi?id=376898

[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Version Fixed In|                            |5.5.0
      Latest Commit|                            |https://commits.kde.org/dig
                   |                            |ikam/4cc8880fa70a943d8b1978
                   |                            |b7987b3a47bd586e8d
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #2 from [hidden email] ---
Git commit 4cc8880fa70a943d8b1978b7987b3a47bd586e8d by Gilles Caulier.
Committed on 25/02/2017 at 08:55.
Pushed by cgilles into branch 'master'.

apply patch from [hidden email] to prevent crash when Exif::Jis comment
is badly encoded with empty string.
Fix coding style and polish
FIXED-IN: 5.5.0

M  +57   -35   libs/dmetadata/metaengine_p.cpp
M  +15   -15   libs/dmetadata/metaengine_p.h

https://commits.kde.org/digikam/4cc8880fa70a943d8b1978b7987b3a47bd586e8d

--
You are receiving this mail because:
You are the assignee for the bug.