GraphicsMagick: ReadOnePNGImage() Change ping_file_depth to unsi...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.15237.1668043248.1459.graphicsmagick-commit@lists.sourceforge.net>
changeset 6ccfd7d001df in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=6ccfd7d001df
summary: ReadOnePNGImage() Change ping_file_depth to unsigned and add verifications for ping_bit_depth.

diffstat:

 ChangeLog          |   7 +++++--
 coders/png.c       |  17 ++++++++++++++---
 www/Changelog.html |   7 +++++++
 3 files changed, 26 insertions(+), 5 deletions(-)

diffs (97 lines):

diff -r 28bdb8ee8efc -r 6ccfd7d001df ChangeLog
--- a/ChangeLog	Wed Nov 09 12:12:27 2022 -0600
+++ b/ChangeLog	Wed Nov 09 19:20:38 2022 -0600
@@ -1,8 +1,12 @@
+2022-11-09  Bob Friesenhahn  <[email protected]>
+
+	* coders/png.c (ReadOnePNGImage): Change ping_file_depth to
+	unsigned and add verifications for ping_bit_depth.
+
 2022-11-09 Fojtik Jaroslav  <[email protected]>
 
         * coders/fits.c Store multiple scenes into one file.
 
-
 2022-11-08  Bob Friesenhahn  <[email protected]>
 
 	* coders/png.c (ReadOnePNGImage): More work on Coverity issue 381864.
@@ -49,7 +53,6 @@
         * coders/wpg.c Shrink amount of colors when palette is bigger than
         raster could store.
 
-
 2022-11-03  Bob Friesenhahn  <[email protected]>
 
 	* magick/blob.c (ReadBlobString): Fix oss-fuzz issue 53001
diff -r 28bdb8ee8efc -r 6ccfd7d001df coders/png.c
--- a/coders/png.c	Wed Nov 09 12:12:27 2022 -0600
+++ b/coders/png.c	Wed Nov 09 19:20:38 2022 -0600
@@ -1506,6 +1506,9 @@
     ping_rowbytes,
     row_offset;
 
+  unsigned int
+    ping_file_depth;
+
   int
     logging,
     num_text,
@@ -1513,7 +1516,6 @@
     pass,
     ping_bit_depth,
     ping_colortype,
-    ping_file_depth,
     ping_interlace_method,
     ping_compression_method,
     ping_filter_method,
@@ -1803,8 +1805,6 @@
     image->depth=8;
 #endif
 
-  ping_file_depth = ping_bit_depth;
-
   /* Save bit-depth and color-type in case we later want to write a PNG00 */
   {
       char
@@ -1849,6 +1849,15 @@
     png_error(ping, "Number of pixels exceeds resource limit");
   }
 
+  if (ping_bit_depth != 1 &&
+      ping_bit_depth != 2 &&
+      ping_bit_depth != 4 &&
+      ping_bit_depth != 8 &&
+      ping_bit_depth != 16)
+    {
+      png_error(ping, "Bit depth is not valid");
+    }
+
   if (ping_bit_depth < 8)
     {
        png_set_packing(ping);
@@ -1856,6 +1865,8 @@
        image->depth=8;
     }
 
+  ping_file_depth = (unsigned int) ping_bit_depth;
+
 #if defined(PNG_READ_iCCP_SUPPORTED)
     if (png_get_valid(ping, ping_info, PNG_INFO_iCCP))
     {
diff -r 28bdb8ee8efc -r 6ccfd7d001df www/Changelog.html
--- a/www/Changelog.html	Wed Nov 09 12:12:27 2022 -0600
+++ b/www/Changelog.html	Wed Nov 09 19:20:38 2022 -0600
@@ -37,6 +37,13 @@
 </div>
 
 <div class="document">
+<p>2022-11-09  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/png.c (ReadOnePNGImage): Change ping_file_depth to
+unsigned and add verifications for ping_bit_depth.</p></li>
+</ul>
+</blockquote>
 <p>2022-11-09 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>
 <blockquote>
 <ul class="simple">
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.