GraphicsMagick: coders/bmp.c: Emit error when ExportImagePixelAr...

GraphicsMagick Commits <[email protected]> Sun, 08 Oct 2023 18:25:20 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.7164.1696807534.7975.graphicsmagick-commit@lists.sourceforge.net>
changeset 9ad869830c16 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=9ad869830c16
summary: coders/bmp.c: Emit error when ExportImagePixelArea fails. This should fix oss-fuzz-63096 issue.

diffstat:

 ChangeLog    |  5 +++++
 coders/bmp.c |  5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diffs (27 lines):

diff -r e5a32c8a0135 -r 9ad869830c16 ChangeLog
--- a/ChangeLog	Sun Oct 08 12:44:21 2023 -0500
+++ b/ChangeLog	Mon Oct 09 01:24:42 2023 +0200
@@ -1,3 +1,8 @@
+2023-10-02  Fojtik Jaroslav  <[email protected]>
+
+	* coders/bmp.c: Emit error when ExportImagePixelArea fails.
+	This should fix oss-fuzz-63096 issue.
+
 2023-10-08  Bob Friesenhahn  <[email protected]>
 
 	* coders/wpg.c (ReadWPGImage): Add a FIXME comment for a bug yet
diff -r e5a32c8a0135 -r 9ad869830c16 coders/bmp.c
--- a/coders/bmp.c	Sun Oct 08 12:44:21 2023 -0500
+++ b/coders/bmp.c	Mon Oct 09 01:24:42 2023 +0200
@@ -2480,6 +2480,11 @@
                 if (ExportImagePixelArea(image,IndexQuantum,8,q,&export_options,0)
                     == MagickFail)
                   {
+                      /* Please note that pixels array has uninitialised elements when this fails. */
+                    if(logging)
+                      (void)LogMagickEvent(CoderEvent,GetMagickModule(),
+                                    "  ExportImagePixelArea failed at row %u", y);
+                    ThrowWriterException(CoderError,DataEncodingSchemeIsNotSupported,image);
                     break;
                   }
                 if (image->previous == (Image *) NULL)