GraphicsMagick: coders/topol.c: Fix situation when GetBlobSize r...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.885.1683324221.1366.graphicsmagick-commit@lists.sourceforge.net>
changeset 1364345f71bf in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=1364345f71bf
summary: coders/topol.c: Fix situation when GetBlobSize returns negative value.

diffstat:

 ChangeLog      |   4 ++++
 coders/topol.c |  11 +++++++----
 2 files changed, 11 insertions(+), 4 deletions(-)

diffs (36 lines):

diff -r ffb178285bcb -r 1364345f71bf ChangeLog
--- a/ChangeLog	Fri May 05 11:26:31 2023 -0500
+++ b/ChangeLog	Sat May 06 00:03:08 2023 +0200
@@ -1,3 +1,7 @@
+2023-05-06  Fojtik Jaroslav  <[email protected]>
+
+	* coders/topol.c: Fix situation when GetBlobSize returns negative value.
+
 2023-05-05  Bob Friesenhahn  <[email protected]>
 
 	* coders/heif.c (ReadHEIFImage): Implemented Tobias Mark's idea
diff -r ffb178285bcb -r 1364345f71bf coders/topol.c
--- a/coders/topol.c	Fri May 05 11:26:31 2023 -0500
+++ b/coders/topol.c	Sat May 06 00:03:08 2023 +0200
@@ -540,14 +540,17 @@
   image->columns = Header.Cols;
   image->rows = Header.Rows;
 
-  i = GetBlobSize(image);
-  if(i>0)
-    if(((magick_uint64_t)depth*Header.Cols*(magick_uint64_t)Header.Rows) / 8 > (magick_uint64_t)GetBlobSize(image))
-      goto TOPOL_KO;    /* Check for forged image that overflows file size. */
+  j = GetBlobSize(image);
+  if(j<512)			// Header size=512bytes; negative number means failure.
+      goto TOPOL_KO;
 
   /* If ping is true, then only set image size and colors without reading any image data. */
   if (image_info->ping) goto DONE_READING;
 
+  if(j>=512)
+      if(((magick_uint64_t)depth*Header.Cols*(magick_uint64_t)Header.Rows) / 8 > (magick_uint64_t)GetBlobSize(image))
+        goto TOPOL_KO;    /* Check for forged image that overflows file size. */
+
   /* ----- Handle the reindexing mez file ----- */
   j = image->colors;
   if(j<=0 || j>256) j=256;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.