GraphicsMagick: ReadMIFFImage(): Handle unexpected EOF in versio...

GraphicsMagick Commits <[email protected]> Fri, 08 Dec 2023 12:50:10 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.10630.1702061426.1716.graphicsmagick-commit@lists.sourceforge.net>
changeset f3d951a66193 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=f3d951a66193
summary: ReadMIFFImage(): Handle unexpected EOF in version 0 bzip2 compressed MIFF.

diffstat:

 ChangeLog          |  4 ++++
 coders/miff.c      |  6 ++++++
 www/Changelog.html |  3 +++
 3 files changed, 13 insertions(+), 0 deletions(-)

diffs (42 lines):

diff -r 8e80ed0df3fb -r f3d951a66193 ChangeLog
--- a/ChangeLog	Fri Dec 08 09:41:11 2023 -0600
+++ b/ChangeLog	Fri Dec 08 12:50:07 2023 -0600
@@ -1,5 +1,9 @@
 2023-12-08  Bob Friesenhahn  <[email protected]>
 
+	* coders/miff.c (ReadMIFFImage): Handle unexpected EOF in version
+	0 bzip2 compressed MIFF.  Addresses oss-fuzz "Issue 64851:
+	graphicsmagick:coder_MIFF_fuzzer: Timeout in coder_MIFF_fuzzer".
+
 	* coders/jbig.c (ReadJBIGImage): Add error detection. Addresses
 	oss-fuzz "Issue 64781: graphicsmagick:coder_JBIG_fuzzer:
 	Null-dereference READ in jbg_dec_getimage".
diff -r 8e80ed0df3fb -r f3d951a66193 coders/miff.c
--- a/coders/miff.c	Fri Dec 08 09:41:11 2023 -0600
+++ b/coders/miff.c	Fri Dec 08 12:50:07 2023 -0600
@@ -1859,6 +1859,12 @@
                         {
                           length=(int) (1.01*pixels_size+600);
                           bzip_info.avail_in=(unsigned int) ReadBlob(image,length,bzip_info.next_in);
+                          if (bzip_info.avail_in == 0)
+                            {
+                              (void) BZ2_bzDecompressEnd(&bzip_info);
+                              ThrowMIFFReaderException(CorruptImageError,UnexpectedEndOfFile,
+                                                   image);
+                            }
                         }
                       else
                         {
diff -r 8e80ed0df3fb -r f3d951a66193 www/Changelog.html
--- a/www/Changelog.html	Fri Dec 08 09:41:11 2023 -0600
+++ b/www/Changelog.html	Fri Dec 08 12:50:07 2023 -0600
@@ -40,6 +40,9 @@
 <p>2023-12-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/miff.c (ReadMIFFImage): Handle unexpected EOF in version
+0 bzip2 compressed MIFF.  Addresses oss-fuzz &quot;Issue 64851:
+graphicsmagick:coder_MIFF_fuzzer: Timeout in coder_MIFF_fuzzer&quot;.</p></li>
 <li><p>coders/jbig.c (ReadJBIGImage): Add error detection. Addresses
 oss-fuzz &quot;Issue 64781: graphicsmagick:coder_JBIG_fuzzer:
 Null-dereference READ in jbg_dec_getimage&quot;.</p></li>