File htmldoc-CVE-2022-24191.patch of Package htmldoc.17472
commit fb0334a51300988e9b83b9870d4063e86002b077
Author: Michael R Sweet <michael.r.sweet@gmail.com>
Date: Tue Jan 25 18:11:34 2022 -0500
Fix a potential stack overflow bug with GIF images (Issue #470)
diff --git a/htmldoc/image.cxx b/htmldoc/image.cxx
index a483784..550b0f9 100644
--- a/htmldoc/image.cxx
+++ b/htmldoc/image.cxx
@@ -465,7 +465,6 @@ gif_read_lzw(FILE *fp, /* I - File to read from */
{
uchar buf[260];
-
if (!gif_eof)
while (gif_get_block(fp, buf) > 0);
@@ -482,17 +481,23 @@ gif_read_lzw(FILE *fp, /* I - File to read from */
while (code >= clear_code)
{
+ if (sp >= (stack + sizeof(stack)))
+ return (255);
+
*sp++ = table[1][code];
+
if (code == table[0][code])
return (255);
code = table[0][code];
}
+ if (sp >= (stack + sizeof(stack)))
+ return (255);
+
*sp++ = firstcode = table[1][code];
- code = max_code;
- if (code < 4096)
+ if ((code = max_code) < 4096)
{
table[0][code] = oldcode;
table[1][code] = firstcode;