GraphicsMagick: ReadBMPImage(): Adjust expected bmp_info.size (c...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.7548.1691527154.1374.graphicsmagick-commit@lists.sourceforge.net>
changeset 4b2b1c4ecfda in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=4b2b1c4ecfda
summary: ReadBMPImage(): Adjust expected bmp_info.size (change 64 to 120)

diffstat:

 ChangeLog          |   1 +
 coders/bmp.c       |  11 +++++++----
 www/Changelog.html |   3 ++-
 3 files changed, 10 insertions(+), 5 deletions(-)

diffs (68 lines):

diff -r 0a8640cc344d -r 4b2b1c4ecfda ChangeLog
--- a/ChangeLog	Tue Aug 08 14:34:04 2023 -0500
+++ b/ChangeLog	Tue Aug 08 15:38:59 2023 -0500
@@ -1,6 +1,7 @@
 2023-08-08  Bob Friesenhahn  <[email protected]>
 
 	* coders/bmp.c (ReadBMPImage): Re-indent/format for consistency.
+	(ReadBMPImage): Adjust expected bmp_info.size (change 64 to 120).
 
 2023-08-08  Fojtik Jaroslav  <[email protected]>
 
diff -r 0a8640cc344d -r 4b2b1c4ecfda coders/bmp.c
--- a/coders/bmp.c	Tue Aug 08 14:34:04 2023 -0500
+++ b/coders/bmp.c	Tue Aug 08 15:38:59 2023 -0500
@@ -650,7 +650,7 @@
             break;
         }
 
-      if (count != 2)		/* Found "BA" header from above above */
+      if (count != 2)           /* Found "BA" header from above above */
         ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
 
       if (logging )
@@ -675,10 +675,10 @@
                               bmp_info.offset_bits,
                               bmp_info.ba_offset);
 
-      if (LocaleNCompare((char *) magick,"BM",2) != 0)	/* "BM" is Windows or OS/2 file. */
+      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 */
+              (bmp_info.size!=12 && bmp_info.size!=40)) /* CI chunk must have biSize only 12 or 40 */
             ThrowBMPReaderException(CorruptImageError,ImproperImageHeader,image);
         }
 
@@ -829,7 +829,7 @@
                                           "Alpha Mask: 0x%04x",
                                           bmp_info.alpha_mask);
 
-                  if (bmp_info.size > 64)
+                  if (bmp_info.size > 120)
                     {
                       /*
                         https://learn.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-bitmapv4header
@@ -999,6 +999,9 @@
             }
         }
 
+      if (EOFBlob(image))
+        ThrowBMPReaderException(CorruptImageError,UnexpectedEndOfFile,image);
+
       if (logging)
         (void) LogMagickEvent(CoderEvent,GetMagickModule(),
                               "  File size: Claimed=%" MAGICK_SIZE_T_F "u, Actual=%"
diff -r 0a8640cc344d -r 4b2b1c4ecfda www/Changelog.html
--- a/www/Changelog.html	Tue Aug 08 14:34:04 2023 -0500
+++ b/www/Changelog.html	Tue Aug 08 15:38:59 2023 -0500
@@ -40,7 +40,8 @@
 <p>2023-08-08  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li><p>coders/bmp.c (ReadBMPImage): Re-indent/format for consistency.</p></li>
+<li><p>coders/bmp.c (ReadBMPImage): Re-indent/format for consistency.
+(ReadBMPImage): Adjust expected bmp_info.size (change 64 to 120).</p></li>
 </ul>
 </blockquote>
 <p>2023-08-08  Fojtik Jaroslav  &lt;<a class="reference external" href="mailto:JaFojtik&#37;&#52;&#48;yandex&#46;com">JaFojtik<span>&#64;</span>yandex<span>&#46;</span>com</a>&gt;</p>
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.