gif loader fixes



Here is a patch which makes the gif
loader survive 

TEST_RANDOMLY_MODIFIED (valid_gif_test, FALSE)

OK to commit ?

Index: io-gif.c
===================================================================
RCS file: /cvs/gnome/gtk+/gdk-pixbuf/io-gif.c,v
retrieving revision 1.57
diff -u -3 -p -u -r1.57 io-gif.c
--- io-gif.c	2001/06/08 20:15:49	1.57
+++ io-gif.c	2001/08/29 08:51:12
@@ -613,6 +613,15 @@ lzw_read_byte (GifContext *context)
 		}
 
 		while (code >= context->lzw_clear_code) {
+                        if ((code >= (1 << MAX_LZW_BITS)) 
+                            || (context->lzw_sp >= context->lzw_stack + ((1 
<< (MAX_LZW_BITS)) * 2 + 1))) {
+                                g_set_error (context->error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Bad code encountered"));
+				return -2;
+                        }
+
 			*(context->lzw_sp)++ = context->lzw_table[1][code];
 
 			if (code == context->lzw_table[0][code]) {
@@ -1038,7 +1047,7 @@ gif_init (GifContext *context)
                              GDK_PIXBUF_ERROR,
                              GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
                              _("File does not appear to be a GIF file"));
-		return -1;
+		return -2;
 	}
 
 	strncpy (version, (char *) buf + 3, 3);
@@ -1051,7 +1060,7 @@ gif_init (GifContext *context)
                              GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
                              _("Version %s of the GIF file format is not 
supported"),
                              version);
-		return -1;
+		return -2;
 	}
 
 	/* read the screen descriptor */




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]