openbsd-ports/graphics/ImageMagick/patches/patch-coders_gif_c
brad 7982d4d3e5 - Don't allow a corrupt GIF image to overflow pixel stack
- Prevent buffer overruns when decoding runlength-encoded images in the BMP format
2004-09-21 18:39:15 +00:00

22 lines
783 B
Plaintext

$OpenBSD: patch-coders_gif_c,v 1.1 2004/09/21 18:39:15 brad Exp $
--- coders/gif.c.orig Tue Sep 21 03:42:27 2004
+++ coders/gif.c Tue Sep 21 03:43:39 2004
@@ -261,6 +261,8 @@ static unsigned int DecodeImage(Image *i
}
while (code >= clear)
{
+ if ((top_stack-pixel_stack) >= MaxStackSize)
+ break;
*top_stack++=suffix[code];
code=(unsigned long) prefix[code];
}
@@ -268,6 +270,8 @@ static unsigned int DecodeImage(Image *i
/*
Add a new string to the string table,
*/
+ if ((top_stack-pixel_stack) >= MaxStackSize)
+ break;
if (available >= MaxStackSize)
break;
*top_stack++=(unsigned char) first;