check to avoid overwriting
authorClaus Gittinger <cg@exept.de>
Fri, 21 Aug 1998 23:36:48 +0200
changeset 2261 740be162343e
parent 2260 954c7dce96aa
child 2262 c97df93c1781
check to avoid overwriting
ImageRdr.st
ImageReader.st
--- a/ImageRdr.st	Fri Aug 21 19:48:27 1998 +0200
+++ b/ImageRdr.st	Fri Aug 21 23:36:48 1998 +0200
@@ -778,6 +778,13 @@
 		if (outCount > 1024) {
 		    goto out;
 		}
+
+	        /* debugging and protecting myself from overwrites */
+	        if (curCode >= 4096) {
+		    fprintf(stderr, "ImageReader [warning]: GIF corrupted input (code > 4095)\n");
+		    ret = 0;
+		    break;
+	        }
 		outCode[outCount++] = suffix[curCode];
 		curCode = prefix[curCode];
 	    }
@@ -802,6 +809,13 @@
 	    }
 	    outCount = 0;
 
+            /* debugging and protecting myself from overwrites */
+            if (freeCode >= 4096) {
+                fprintf(stderr, "ImageReader [warning]: GIF corrupted input (freeCode > 4095)\n");
+                ret = 0;
+                break;
+            }
+
 	    prefix[freeCode] = oldCode;
 	    suffix[freeCode] = fin;
 	    oldCode = inCode;
@@ -2055,5 +2069,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/ImageRdr.st,v 1.65 1998-06-15 15:08:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/ImageRdr.st,v 1.66 1998-08-21 21:36:48 cg Exp $'
 ! !
--- a/ImageReader.st	Fri Aug 21 19:48:27 1998 +0200
+++ b/ImageReader.st	Fri Aug 21 23:36:48 1998 +0200
@@ -778,6 +778,13 @@
 		if (outCount > 1024) {
 		    goto out;
 		}
+
+	        /* debugging and protecting myself from overwrites */
+	        if (curCode >= 4096) {
+		    fprintf(stderr, "ImageReader [warning]: GIF corrupted input (code > 4095)\n");
+		    ret = 0;
+		    break;
+	        }
 		outCode[outCount++] = suffix[curCode];
 		curCode = prefix[curCode];
 	    }
@@ -802,6 +809,13 @@
 	    }
 	    outCount = 0;
 
+            /* debugging and protecting myself from overwrites */
+            if (freeCode >= 4096) {
+                fprintf(stderr, "ImageReader [warning]: GIF corrupted input (freeCode > 4095)\n");
+                ret = 0;
+                break;
+            }
+
 	    prefix[freeCode] = oldCode;
 	    suffix[freeCode] = fin;
 	    oldCode = inCode;
@@ -2055,5 +2069,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.65 1998-06-15 15:08:11 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.66 1998-08-21 21:36:48 cg Exp $'
 ! !