GraphicsMagick: ReadPNMImage(): Make sure that we don't lose the...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.92.1642036527.1376.graphicsmagick-commit@lists.sourceforge.net>
changeset 00cac4541812 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=00cac4541812
summary: ReadPNMImage(): Make sure that we don't lose the image exception

diffstat:

 ChangeLog                              |  9 +++++++++
 VisualMagick/installer/inc/version.isx |  4 ++--
 coders/pnm.c                           |  7 +++++--
 magick/blob.c                          |  2 +-
 magick/version.h                       |  4 ++--
 www/Changelog.html                     |  8 ++++++++
 6 files changed, 27 insertions(+), 7 deletions(-)

diffs (95 lines):

diff -r 024041c500c7 -r 00cac4541812 ChangeLog
--- a/ChangeLog	Tue Jan 11 18:12:46 2022 -0600
+++ b/ChangeLog	Wed Jan 12 19:14:50 2022 -0600
@@ -1,3 +1,12 @@
+2022-01-12  Bob Friesenhahn  <[email protected]>
+
+        * magick/blob.c (ReadBlob): Fix EOF logic. Addresses oss-fuzz
+        43490 "graphicsmagick:coder_PNM_fuzzer: Use-of-uninitialized-value
+        in SyncImageCallBack".
+
+        * coders/pnm.c (ReadPNMImage): Make sure that we don't lose the
+        image exception.
+
 2022-01-11  Bob Friesenhahn  <[email protected]>
 
         * magick/blob.c: Throw a user-friendly exception when the read
diff -r 024041c500c7 -r 00cac4541812 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Tue Jan 11 18:12:46 2022 -0600
+++ b/VisualMagick/installer/inc/version.isx	Wed Jan 12 19:14:50 2022 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020220111"
-#define public MagickPackageReleaseDate "snapshot-20220111"
+#define public MagickPackageVersionAddendum ".020220112"
+#define public MagickPackageReleaseDate "snapshot-20220112"
diff -r 024041c500c7 -r 00cac4541812 coders/pnm.c
--- a/coders/pnm.c	Tue Jan 11 18:12:46 2022 -0600
+++ b/coders/pnm.c	Wed Jan 12 19:14:50 2022 -0600
@@ -1152,15 +1152,18 @@
             DestroyThreadViewDataSet(scanline_set);
             image->is_monochrome=is_monochrome;
             image->is_grayscale=is_grayscale;
+            if ((status == MagickFail) && (image->exception.severity))
+              CopyException(exception,&image->exception);
             if (EOFBlob(image))
-              ThrowException(exception,CorruptImageError,UnexpectedEndOfFile,
-                             image->filename);
+              ThrowReaderException(CorruptImageError,UnexpectedEndOfFile,image);
             break;
           }
         default:
           ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
         }
       StopTimer(&image->timer);
+      if (status ==MagickFail)
+        break;
       /*
         Proceed to next image.
       */
diff -r 024041c500c7 -r 00cac4541812 magick/blob.c
--- a/magick/blob.c	Tue Jan 11 18:12:46 2022 -0600
+++ b/magick/blob.c	Wed Jan 12 19:14:50 2022 -0600
@@ -3365,7 +3365,7 @@
     }
   assert(count <= length);
   blob->read_total += count;
-  if (count == 0)
+  if (count < req_length)
     {
       blob->eof=True;
       if (blob->read_limit <= blob->read_total)
diff -r 024041c500c7 -r 00cac4541812 magick/version.h
--- a/magick/version.h	Tue Jan 11 18:12:46 2022 -0600
+++ b/magick/version.h	Wed Jan 12 19:14:50 2022 -0600
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x262300
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 26,23,0
-#define MagickChangeDate   "20220111"
-#define MagickReleaseDate  "snapshot-20220111"
+#define MagickChangeDate   "20220112"
+#define MagickReleaseDate  "snapshot-20220112"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r 024041c500c7 -r 00cac4541812 www/Changelog.html
--- a/www/Changelog.html	Tue Jan 11 18:12:46 2022 -0600
+++ b/www/Changelog.html	Wed Jan 12 19:14:50 2022 -0600
@@ -35,6 +35,14 @@
 <div class="document">
 
 
+<p>2022-01-12  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>
+<p>* magick/blob.c (ReadBlob): Fix EOF logic. Addresses oss-fuzz
+43490 &quot;graphicsmagick:coder_PNM_fuzzer: Use-of-uninitialized-value
+in SyncImageCallBack&quot;.</p>
+<p>* coders/pnm.c (ReadPNMImage): Make sure that we don't lose the
+image exception.</p>
+</blockquote>
 <p>2022-01-11  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>
 <p>* magick/blob.c: Throw a user-friendly exception when the read
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.