From 61857770ce695f7316b0b3ab338478570b93f221 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 31 May 2002 23:42:33 +0000 Subject: [PATCH] Accept xbms starting with a C comment - those seem to be not uncommon, * gdk-pixbuf-io.c (pixbuf_check_xbm): Accept xbms starting with a C comment - those seem to be not uncommon, e.g. the Gimp produces them. (#82706) * io-xbm.c (read_bitmap_file_data): Don't leak memory on certain invalid inputs. (gdk_pixbuf__xbm_image_load_real): Don't leak memory on valid inputs. --- gdk-pixbuf/ChangeLog | 10 ++++++++++ gdk-pixbuf/gdk-pixbuf-io.c | 25 +++++++++++++++---------- gdk-pixbuf/io-xbm.c | 2 ++ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog index 1de74afbe0..e81f8ab48b 100644 --- a/gdk-pixbuf/ChangeLog +++ b/gdk-pixbuf/ChangeLog @@ -1,3 +1,13 @@ +2002-06-01 Matthias Clasen + + * gdk-pixbuf-io.c (pixbuf_check_xbm): Accept xbms starting + with a C comment - those seem to be not uncommon, e.g. the Gimp + produces them. (#82706) + + * io-xbm.c (read_bitmap_file_data): Don't leak memory on certain + invalid inputs. + (gdk_pixbuf__xbm_image_load_real): Don't leak memory on valid inputs. + 2002-05-22 Tor Lillqvist * gdk-pixbuf-io.c (get_libdir): Use GTK_BINARY_VERSION (and not diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c index b0e03319a8..b32da24dbe 100644 --- a/gdk-pixbuf/gdk-pixbuf-io.c +++ b/gdk-pixbuf/gdk-pixbuf-io.c @@ -193,17 +193,22 @@ pixbuf_check_xbm (guchar *buffer, int size) if (size < 20) return FALSE; - if (buffer [0] != '#' - || buffer [1] != 'd' - || buffer [2] != 'e' - || buffer [3] != 'f' - || buffer [4] != 'i' - || buffer [5] != 'n' - || buffer [6] != 'e' - || buffer [7] != ' ') - return FALSE; + if (buffer [0] == '#' + && buffer [1] == 'd' + && buffer [2] == 'e' + && buffer [3] == 'f' + && buffer [4] == 'i' + && buffer [5] == 'n' + && buffer [6] == 'e' + && buffer [7] == ' ') + return TRUE; - return TRUE; + /* Note that this requires xpm to be checked before xbm. */ + if (buffer [0] == '/' + && buffer [1] != '*') + return TRUE; + + return FALSE; } static gboolean diff --git a/gdk-pixbuf/io-xbm.c b/gdk-pixbuf/io-xbm.c index d1a087e447..3ef06bb2a8 100644 --- a/gdk-pixbuf/io-xbm.c +++ b/gdk-pixbuf/io-xbm.c @@ -244,6 +244,7 @@ read_bitmap_file_data (FILE *fstream, *ptr=value; } } + break; } if (!bits) @@ -323,6 +324,7 @@ gdk_pixbuf__xbm_image_load_real (FILE *f, XBMData *context, GError **error) } pixels += row_stride; } + g_free (data); if (context) { (* context->update_func) (pixbuf, 0, 0, w, h, context->user_data);