GNOME Bugzilla – Bug 85448
crash in loading bmp
Last modified: 2010-07-10 04:04:05 UTC
Package: gtk+ Severity: major Version: 2.0.0 Synopsis: crash in loading bmp Bugzilla-Product: gtk+ Bugzilla-Component: gdk-pixbuf BugBuddy-GnomeVersion: 2.0 (2.0.1) Description: Description of Problem: This is nautilus browsing a windows c:\windows directory. I hope I read the backtrace right in that that is a gdk bug. I'll attach the file in question. Debugging Information: Backtrace was generated from '/gnome/head/INSTALL/bin/nautilus' 0x40bbca39 in wait4 () from /lib/libc.so.6
+ Trace 23891
------- Bug moved to this database by unknown@bugzilla.gnome.org 2002-06-16 05:36 ------- Reassigning to the default owner of the component, gtk-bugs@gtk.org.
Created attachment 9252 [details] the file mentioned in the backtrace
Crash verified. Seems to be a combination of something going wrong with header parsing and an unchecked g_realloc().
The bmp in question is invalid, it contains a wrong offset field. bmptoppm correctly complains about this (and even tells the correct value), but of course gdk-pixbuf shouldn't crash on any image. Interestingly, ImageMagick and xv manage to display the bmp correctly, since they don't use the offset field in question. Here is a first patch which a) removes all unchecked reallocs from io-bmp.c and b) makes gdk-pixbuf display the invalid bmp by not using the offset field in question, in the same way xv and ImageMagick do. There are more problems in io-bmp.c though. valgrind reports some memleaks and invalid reads.
Created attachment 9400 [details] [review] patch
Turns out the only change I need in order to silence valgrind is to change the Compressed field in the bmp_progressive_state struct from gint to guint, so that negative values don't slip through the sanity checks in DecodeHeader.
The change to the offset calculation for displaying the broken bmp breaks loading of certain valid bmps, thus the old code should probably be left in place.
Crash fix committed to both branches.
Reopened for pixbuf-stable.
Backported, marking as fixed.