fixed destination-array boundary check (in GIF-decode)
authorClaus Gittinger <cg@exept.de>
Sun, 25 Jan 1998 15:12:36 +0100
changeset 2014 bcae1c2c32e4
parent 2013 d77c7dcbf840
child 2015 f53883507ed9
fixed destination-array boundary check (in GIF-decode)
ImageRdr.st
ImageReader.st
--- a/ImageRdr.st	Sun Jan 25 15:11:43 1998 +0100
+++ b/ImageRdr.st	Sun Jan 25 15:12:36 1998 +0100
@@ -785,13 +785,21 @@
 	    fin = curCode;
 	    outCode[outCount++] = fin;
 
+#if 0
 	    if ((to+outCount) >= toEnd) {
 		fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
 	        ret = 0;
 	        break;
 	    }
-	    for (i = outCount - 1; i >= 0; i--)
+#endif
+	    for (i = outCount - 1; i >= 0; i--) {
+	        if (to >= toEnd) {
+		    fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
+	            ret = 0;
+	            break;
+	        }
 		*to++ = outCode[i];
+	    }
 	    outCount = 0;
 
 	    prefix[freeCode] = oldCode;
@@ -1936,5 +1944,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/Attic/ImageRdr.st,v 1.58 1998-01-19 17:16:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/Attic/ImageRdr.st,v 1.59 1998-01-25 14:12:36 cg Exp $'
 ! !
--- a/ImageReader.st	Sun Jan 25 15:11:43 1998 +0100
+++ b/ImageReader.st	Sun Jan 25 15:12:36 1998 +0100
@@ -785,13 +785,21 @@
 	    fin = curCode;
 	    outCode[outCount++] = fin;
 
+#if 0
 	    if ((to+outCount) >= toEnd) {
 		fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
 	        ret = 0;
 	        break;
 	    }
-	    for (i = outCount - 1; i >= 0; i--)
+#endif
+	    for (i = outCount - 1; i >= 0; i--) {
+	        if (to >= toEnd) {
+		    fprintf(stderr, "ImageReader [warning]: GIF outBuffer overrun\n");
+	            ret = 0;
+	            break;
+	        }
 		*to++ = outCode[i];
+	    }
 	    outCount = 0;
 
 	    prefix[freeCode] = oldCode;
@@ -1936,5 +1944,5 @@
 !ImageReader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.58 1998-01-19 17:16:05 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ImageReader.st,v 1.59 1998-01-25 14:12:36 cg Exp $'
 ! !