GraphicsMagick: ReadTIFFImage(): Verify that the bits per sample...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.266.1684601951.20881.graphicsmagick-commit@lists.sourceforge.net>
changeset 279b3aa0832a in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=279b3aa0832a
summary: ReadTIFFImage(): Verify that the bits per sample is suitable for the claimed compressor

diffstat:

 ChangeLog          |   3 +++
 coders/tiff.c      |  37 +++++++++++++++++++++++++++++++++++++
 www/Changelog.html |   2 ++
 3 files changed, 42 insertions(+), 0 deletions(-)

diffs (78 lines):

diff -r 03f9cc8ab2ef -r 279b3aa0832a ChangeLog
--- a/ChangeLog	Sat May 20 09:10:16 2023 -0500
+++ b/ChangeLog	Sat May 20 11:15:31 2023 -0500
@@ -1,5 +1,8 @@
 2023-05-20  Bob Friesenhahn  <[email protected]>
 
+	* coders/tiff.c (ReadTIFFImage): Verify that the bits per sample
+	is suitable for the claimed compressor.
+
 	* coders/bmp.c (ReadBMPImage): Do not decode primaries or gamma
 	unless colorspace is LCS_CALIBRATED_RGB.
 
diff -r 03f9cc8ab2ef -r 279b3aa0832a coders/tiff.c
--- a/coders/tiff.c	Sat May 20 09:10:16 2023 -0500
+++ b/coders/tiff.c	Sat May 20 11:15:31 2023 -0500
@@ -2225,6 +2225,7 @@
 
           if (extra_samples != 0)
             {
+              /* FIXME: Is it ok to make this gross assumption? */
               alpha_type=AssociatedAlpha;
               image->matte=True;
 
@@ -2395,6 +2396,42 @@
         }
 
       /*
+        Verify that the bits per sample is suitable for the claimed compressor
+      */
+#if defined(COMPRESSION_CCITTFAX3)
+      if ((COMPRESSION_CCITTFAX3 == compress_tag) && (1 != bits_per_sample))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "CCITT FAX3 compression requires 1 bits per sample!");
+          ThrowTIFFReaderException(CoderError,UnsupportedBitsPerSample,image);
+        }
+#endif /* if defined(COMPRESSION_CCITTFAX3) */
+#if defined(COMPRESSION_CCITTFAX4)
+      if ((COMPRESSION_CCITTFAX4 == compress_tag) && (1 != bits_per_sample))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "CCITT FAX4 compression requires 1 bits per sample!");
+          ThrowTIFFReaderException(CoderError,UnsupportedBitsPerSample,image);
+        }
+#endif /* if defined(COMPRESSION_CCITTFAX4) */
+#if defined(COMPRESSION_JBIG)
+      if ((COMPRESSION_JBIG == compress_tag) && (1 != bits_per_sample))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "JBIG compression requires 1 bits per sample!");
+          ThrowTIFFReaderException(CoderError,UnsupportedBitsPerSample,image);
+        }
+#endif /* if defined(COMPRESSION_JBIG) */
+#if defined(COMPRESSION_WEBP)
+      if ((COMPRESSION_WEBP == compress_tag) && (8 != bits_per_sample))
+        {
+          (void) LogMagickEvent(CoderEvent,GetMagickModule(),
+                                "WebP compression requires 8 bits per sample!");
+          ThrowTIFFReaderException(CoderError,UnsupportedBitsPerSample,image);
+        }
+#endif /* if defined(COMPRESSION_WEBP) */
+
+      /*
         Check if the bits-per-sample value is supported by the
         implementation before proceeding.
 
diff -r 03f9cc8ab2ef -r 279b3aa0832a www/Changelog.html
--- a/www/Changelog.html	Sat May 20 09:10:16 2023 -0500
+++ b/www/Changelog.html	Sat May 20 11:15:31 2023 -0500
@@ -40,6 +40,8 @@
 <p>2023-05-20  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/tiff.c (ReadTIFFImage): Verify that the bits per sample
+is suitable for the claimed compressor.</p></li>
 <li><p>coders/bmp.c (ReadBMPImage): Do not decode primaries or gamma
 unless colorspace is LCS_CALIBRATED_RGB.</p></li>
 </ul>
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.