summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorMatthias Clasen <matthiasc@src.gnome.org>2008-06-13 04:23:54 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2008-06-13 04:23:54 +0000
commit58c5051ebdc55fa193d7359d26c1a8aca35c9162 (patch)
tree6cb031593ea3dfa10a81f704b80ac317dec7d449 /gdk-pixbuf
parente9d3e03f9fc0bb8b9791e3e86cfee6a43be49d4c (diff)
downloadgdk-pixbuf-58c5051ebdc55fa193d7359d26c1a8aca35c9162.tar.gz
Fix a crash
svn path=/trunk/; revision=20367
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/io-ico.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/gdk-pixbuf/io-ico.c b/gdk-pixbuf/io-ico.c
index 27937c96b..29dd95a1d 100644
--- a/gdk-pixbuf/io-ico.c
+++ b/gdk-pixbuf/io-ico.c
@@ -199,10 +199,33 @@ static void DecodeHeader(guchar *Data, gint Bytes,
guchar *BIH; /* The DIB for the used icon */
guchar *Ptr;
gint I;
+ guint16 imgtype; /* 1 = icon, 2 = cursor */
/* Step 1: The ICO header */
- State->cursor = ((Data[3] << 8) + Data[2] == 2) ? TRUE : FALSE;
+ /* First word should be 0 according to specs */
+ if (((Data[1] << 8) + Data[0]) != 0) {
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Invalid header in icon"));
+ return;
+
+ }
+
+ imgtype = (Data[3] << 8) + Data[2];
+
+ State->cursor = (imgtype == 2) ? TRUE : FALSE;
+
+ /* If it is not a cursor make sure it is actually an icon */
+ if (!State->cursor && imgtype != 1) {
+ g_set_error (error,
+ GDK_PIXBUF_ERROR,
+ GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+ _("Invalid header in icon"));
+ return;
+ }
+
IconCount = (Data[5] << 8) + (Data[4]);