GraphicsMagick: coders/bmp.c: CI chunk must have biSize only 12 ...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.7098.1691396993.1761.graphicsmagick-commit@lists.sourceforge.net>
changeset 5bd04a2ebedb in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=5bd04a2ebedb
summary: coders/bmp.c: CI chunk must have biSize only 12 or 40.

diffstat:

 ChangeLog    |   4 ++++
 coders/bmp.c |  12 +++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

diffs (34 lines):

diff -r 3d1f076bbcaf -r 5bd04a2ebedb ChangeLog
--- a/ChangeLog	Sun Aug 06 08:24:26 2023 -0500
+++ b/ChangeLog	Mon Aug 07 10:29:00 2023 +0200
@@ -1,3 +1,7 @@
+2023-08-08  Fojtik Jaroslav  <[email protected]>
+
+	* coders/bmp.c: CI chunk must have biSize only 12 or 40.
+
 2023-08-06  Bob Friesenhahn  <[email protected]>
 
 	* coders/tiff.c (ReadTIFFImage): Default field pass count to 1
diff -r 3d1f076bbcaf -r 5bd04a2ebedb coders/bmp.c
--- a/coders/bmp.c	Sun Aug 06 08:24:26 2023 -0500
+++ b/coders/bmp.c	Mon Aug 07 10:29:00 2023 +0200
@@ -652,10 +652,16 @@
     if (logging && count == 2)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),"  Magick: %c%c",
         magick[0],magick[1]);
-    if ((count != 2) || /* Found "BA" header from above above */
-        ((LocaleNCompare((char *) magick,"BM",2) != 0) && /* "BM" is Windows or OS/2 file. */
-         (LocaleNCompare((char *) magick,"CI",2) != 0)))  /* "CI" is OS/2 Color Icon */
+
+    if (count != 2)		/* Found "BA" header from above above */
       ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+     if((LocaleNCompare((char *) magick,"BM",2) != 0)	/* "BM" is Windows or OS/2 file. */
+     {
+       if(LocaleNCompare((char *) magick,"CI",2) != 0)) || )  /* "CI" is OS/2 Color Icon */
+          bmp_info.size!=12 && bmp_info.size!=40)	/* CI chunk must have biSize only 12 or 40 */
+             ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
+     }
+
     bmp_info.file_size=ReadBlobLSBLong(image); /* File size in bytes */
     if (logging)
       (void) LogMagickEvent(CoderEvent,GetMagickModule(),
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.