After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 766824 - Invalid comment string causes export crash
Invalid comment string causes export crash
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: General
git master
Other All
: Normal normal
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2016-05-23 21:21 UTC by C.M.Rogers
Modified: 2016-05-30 16:58 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
The file with invalid comment for testing. (1.59 MB, image/png)
2016-05-23 21:21 UTC, C.M.Rogers
Details

Description C.M.Rogers 2016-05-23 21:21:42 UTC
Created attachment 328409 [details]
The file with invalid comment for testing.

When trying to export the attached file, GIMP crashes when "Save Comment" option is checked on png export.

Several in the gimp-developer email threads confirmed this is a problem with the comment data being invalid/corrupt.

The proposed fix is that GIMP should do some error checking and resolve this issue by binning invalid data and posting a warning, then continuing the export as normal.

-C
Comment 1 Jehan 2016-05-23 21:54:16 UTC
To be accurate: I have not confirmed because I have not tested or checked the file myself. But it was said that non-ASCII characters were used in the Exif's ImageDescription field.

Yet according to the Exif spec (http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf), this field is supposed to be ASCII only apparently
(yes that's sucky, definitely). To use multi-byte encoding, the right field is UserComment. So this may well be the issue (once again, I did not test myself).

Anyway it would be good if GIMP were more robust to otherwise-valid images, even with buggy metadata. In particular, it should not fail to export, but simply discard the wrong metadata field with a warning.
Comment 2 Jehan 2016-05-23 22:33:07 UTC
Someone notes on the ML:

> To make matters worse, the MWG guidelines [0] state that "Exif tags documented in the Exif specification as type ASCII SHOULD be written as UTF-8".
> [0] http://metadataworkinggroup.org/pdf/mwg_guidance.pdf
Comment 3 Jehan 2016-05-23 23:08:35 UTC
I finally tried to open then export your image as PNG. No error, it just works.

In the shell, it indeed outputs some kind of error about wrong metadata contents, but telling it actually does some sensible bypassing: base64-ing the broken data and keeping it in the metadata field (this way it does not fully discard it but in the same time, the metadata is not broken anymore):

> Invalid UTF-8 in metadata value Exif.Image.ImageDescription, encoding as base64: Egk6XHf8AA==
> Invalid UTF-8 in metadata value Exif.Photo.UserComment, encoding as base64: Egk6XHf8AA==

It does not even come from a recent commit (33a8d681, from 2013) so that's weird. On the ML, you say that you actually use the ppa version.
Could you try with the actual git repository and tell us if the problem still happens?
Comment 4 Michael Natterer 2016-05-30 16:58:45 UTC
I would say this fixes it, the comment from the attached image
is rejected by the new validation code, and re-exporting to PNG
works fine:

commit cf3b6903c012c74b787de6eeaa1670adb63ecba2
Author: Michael Natterer <mitch@gimp.org>
Date:   Mon May 30 18:56:29 2016 +0200

    Bug 766824 - Invalid comment string causes export crash
    
    UTF-8 validate the "gimp-comment" parasite and reject it on failure.

 app/core/gimpimage.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)