GraphicsMagick: Do not open Unix compress (.Z) files using Zlib

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.40577.1673118806.1567.graphicsmagick-commit@lists.sourceforge.net>
changeset 24168b310244 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=24168b310244
summary: Do not open Unix compress (.Z) files using Zlib

diffstat:

 ChangeLog          |  29 +++++++++++++++++------------
 magick/blob.c      |  10 ++++------
 magick/image.c     |   1 -
 www/Changelog.html |  46 +++++++++++++++++++---------------------------
 4 files changed, 40 insertions(+), 46 deletions(-)

diffs (239 lines):

diff -r 87b6bae78faf -r 24168b310244 ChangeLog
--- a/ChangeLog	Sat Jan 07 12:48:11 2023 -0600
+++ b/ChangeLog	Sat Jan 07 13:13:12 2023 -0600
@@ -1,5 +1,9 @@
 2023-01-07  Bob Friesenhahn  <[email protected]>
 
+	* magick/blob.c (OpenBlob): Zlib has never supported opening Unix
+	'compress' .Z files (although gzip does).  So don't open such
+	files using zlib.
+
 	* coders/sun.c: Add IM1, IM8, and IM24 magick aliases for Sun
 	Raster format since those are the historically correct extensions.
 
@@ -13,21 +17,22 @@
 	where binary operator is needed.
 
 2023-01-05 Fojtik Jaroslav  <[email protected]>
-	* VisualMagick/installer/inc/body.isx 64 bit distribution MUST NOT be installed on pure
-	32 bit system. Sanity check added.
+
+	* VisualMagick/installer/inc/body.isx 64 bit distribution MUST NOT
+	be installed on pure 32 bit system. Sanity check added.
 
 2023-01-05 Fojtik Jaroslav  <[email protected]>
 
 	* VisualMagick/installer/inc/body.isx
 	* VisualMagick/installer/inc/files-dlls.isx
-	( VisualMagick/installer/redist/VC2008SP1/vcredist_x64.exe must be downloaded from www)
-	( VisualMagick/installer/redist/VC2008SP1/vcredist_x86.exe must be downloaded from www) 
+	(VisualMagick/installer/redist/VC2008SP1/vcredist_x64.exe must be downloaded from www).
+	(VisualMagick/installer/redist/VC2008SP1/vcredist_x86.exe must be downloaded from www).
 	Fix graphics magick installer for Windows.
 
 2023-01-04 Fojtik Jaroslav  <[email protected]>
 
-	* VisualMagick/tests/runtest.bat Added new tests for PGX (jp2), MAT,
-	uncommented test for EPDF and PICON.
+	* VisualMagick/tests/runtest.bat Added new tests for PGX (jp2),
+	MAT, uncommented test for EPDF and PICON.
 
 2023-01-03 Fojtik Jaroslav  <[email protected]>
 
@@ -35,7 +40,7 @@
 
 2023-01-03 Fojtik Jaroslav  <[email protected]>
 
-	+ VisualMagick/jp2/src/libjasper/pgx/LIBRARY.txt
+	* VisualMagick/jp2/src/libjasper/pgx/LIBRARY.txt
 	* jp2/src/libjasper/include/jasper/jas_config.h
 	PGX codec was not compilled into gm, now added.
 
@@ -52,7 +57,7 @@
 
 	* jp2/* Update lib jasper to 2.0.33. Code cleanly compilles, but
 	there is still some problem. Will be solved later.
-	- jp2/src/lib/jasper/include/jasper/stdbool2.h No longer needed.
+	jp2/src/lib/jasper/include/jasper/stdbool2.h No longer needed.
 
 2023-01-01  Bob Friesenhahn  <[email protected]>
 
@@ -72,7 +77,7 @@
 2022-12-30  Fojtik Jaroslav  <[email protected]>
 
 	* coders/pcx.c (WritePCXImage): Meke default RLE compression.
-        Uncompressed PCX is more rare.
+	Uncompressed PCX is more rare.
 
 2022-12-30  Bob Friesenhahn  <[email protected]>
 
@@ -145,8 +150,8 @@
 2022-12-25 Fojtik Jaroslav  <[email protected]>
 
 	* webp/src/webp/types.h Need to include inttypes.h
-        * jp2/src/libjasper/include/jasper/jas_types.h
-		Fix missing _PFX_PTR in newer MSVC.
+	* jp2/src/libjasper/include/jasper/jas_types.h
+	Fix missing _PFX_PTR in newer MSVC.
 
 2022-12-25  Bob Friesenhahn  <[email protected]>
 
@@ -427,7 +432,7 @@
 
 2022-11-20 Fojtik Jaroslav  <[email protected]>
 
-        coders/wpg.c Reveal more internal info to optional log.
+	* coders/wpg.c Reveal more internal info to optional log.
 
 2022-11-19  Bob Friesenhahn  <[email protected]>
 
diff -r 87b6bae78faf -r 24168b310244 magick/blob.c
--- a/magick/blob.c	Sat Jan 07 12:48:11 2023 -0600
+++ b/magick/blob.c	Sat Jan 07 13:13:12 2023 -0600
@@ -2678,8 +2678,8 @@
 %
 %  OpenBlob() opens a file associated with the image.  A file name of '-' sets
 %  the file to stdin for type 'r' and stdout for type 'w'.  If the filename
-%  suffix is '.gz' or '.Z', the image is decompressed for type 'r' and
-%  compressed for type 'w'.
+%  suffix is '.gz', the image is decompressed for type 'r' and compressed
+%  for type 'w'.
 %
 %  The format of the OpenBlob method is:
 %
@@ -2823,9 +2823,7 @@
           (void) strlcpy(filename,image->filename,sizeof(filename));
         }
 #if defined(HasZLIB) && !defined(DISABLE_COMPRESSED_FILES)
-      if (((strlen(filename) > 2) &&
-           (LocaleCompare(filename+strlen(filename)-2,".Z") == 0)) ||
-          ((strlen(filename) > 3) &&
+      if (((strlen(filename) > 3) &&
            (LocaleCompare(filename+strlen(filename)-3,".gz") == 0)) ||
           ((strlen(filename) > 5) &&
            (LocaleCompare(filename+strlen(filename)-5,".svgz") == 0)))
@@ -4627,7 +4625,7 @@
     }
 
   /* Strip trailing NL and CR */
-  while ((i > 0) && ((string[i-1] == '\r') || (string[i-1] == '\n'))) /* oss-fuzz 53001 */
+  while ((i > 0) && ((string[i-1] == '\r') || (string[i-1] == '\n')))
     {
       --i;
       string[i] = 0;
diff -r 87b6bae78faf -r 24168b310244 magick/image.c
--- a/magick/image.c	Sat Jan 07 12:48:11 2023 -0600
+++ b/magick/image.c	Sat Jan 07 13:13:12 2023 -0600
@@ -3146,7 +3146,6 @@
         p--;
 
       if ((LocaleCompare(p,".gz") == 0) ||
-          (LocaleCompare(p,".Z") == 0) ||
           (LocaleCompare(p,".bz2") == 0))
         compressed_extension = MagickTrue;
 
diff -r 87b6bae78faf -r 24168b310244 www/Changelog.html
--- a/www/Changelog.html	Sat Jan 07 12:48:11 2023 -0600
+++ b/www/Changelog.html	Sat Jan 07 13:13:12 2023 -0600
@@ -40,6 +40,9 @@
 <p>2023-01-07  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>magick/blob.c (OpenBlob): Zlib has never supported opening Unix
+'compress' .Z files (although gzip does).  So don't open such
+files using zlib.</p></li>
 <li><p>coders/sun.c: Add IM1, IM8, and IM24 magick aliases for Sun
 Raster format since those are the historically correct extensions.</p></li>
 </ul>
@@ -54,29 +57,28 @@
 where binary operator is needed.</p></li>
 </ul>
 </blockquote>
-<dl class="simple">
-<dt>2023-01-05 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;</dt>
-<dd><ul class="simple">
-<li><p>VisualMagick/installer/inc/body.isx 64 bit distribution MUST NOT be installed on pure
-32 bit system. Sanity check added.</p></li>
+<p>2023-01-05 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">
+<li><p>VisualMagick/installer/inc/body.isx 64 bit distribution MUST NOT
+be installed on pure 32 bit system. Sanity check added.</p></li>
 </ul>
-</dd>
-</dl>
+</blockquote>
 <p>2023-01-05 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">
 <li><p>VisualMagick/installer/inc/body.isx</p></li>
 <li><p>VisualMagick/installer/inc/files-dlls.isx
-( VisualMagick/installer/redist/VC2008SP1/vcredist_x64.exe must be downloaded from www)
-( VisualMagick/installer/redist/VC2008SP1/vcredist_x86.exe must be downloaded from www)
+(VisualMagick/installer/redist/VC2008SP1/vcredist_x64.exe must be downloaded from www).
+(VisualMagick/installer/redist/VC2008SP1/vcredist_x86.exe must be downloaded from www).
 Fix graphics magick installer for Windows.</p></li>
 </ul>
 </blockquote>
 <p>2023-01-04 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">
-<li><p>VisualMagick/tests/runtest.bat Added new tests for PGX (jp2), MAT,
-uncommented test for EPDF and PICON.</p></li>
+<li><p>VisualMagick/tests/runtest.bat Added new tests for PGX (jp2),
+MAT, uncommented test for EPDF and PICON.</p></li>
 </ul>
 </blockquote>
 <p>2023-01-03 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>
@@ -87,16 +89,8 @@
 </blockquote>
 <p>2023-01-03 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>
-<blockquote>
 <ul class="simple">
 <li><p>VisualMagick/jp2/src/libjasper/pgx/LIBRARY.txt</p></li>
-</ul>
-</blockquote>
-<div class="system-message">
-<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">&lt;string&gt;</span>, line 39)</p>
-<p>Block quote ends without a blank line; unexpected unindent.</p>
-</div>
-<ul class="simple">
 <li><p>jp2/src/libjasper/include/jasper/jas_config.h
 PGX codec was not compilled into gm, now added.</p></li>
 </ul>
@@ -119,7 +113,7 @@
 <ul class="simple">
 <li><p>jp2/* Update lib jasper to 2.0.33. Code cleanly compilles, but
 there is still some problem. Will be solved later.
-- jp2/src/lib/jasper/include/jasper/stdbool2.h No longer needed.</p></li>
+jp2/src/lib/jasper/include/jasper/stdbool2.h No longer needed.</p></li>
 </ul>
 </blockquote>
 <p>2023-01-01  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>
@@ -218,12 +212,8 @@
 <blockquote>
 <ul class="simple">
 <li><p>webp/src/webp/types.h Need to include inttypes.h</p></li>
-<li><dl class="simple">
-<dt>jp2/src/libjasper/include/jasper/jas_types.h</dt>
-<dd><p>Fix missing _PFX_PTR in newer MSVC.</p>
-</dd>
-</dl>
-</li>
+<li><p>jp2/src/libjasper/include/jasper/jas_types.h
+Fix missing _PFX_PTR in newer MSVC.</p></li>
 </ul>
 </blockquote>
 <p>2022-12-25  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>
@@ -513,7 +503,9 @@
 </blockquote>
 <p>2022-11-20 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>
-<p>coders/wpg.c Reveal more internal info to optional log.</p>
+<ul class="simple">
+<li><p>coders/wpg.c Reveal more internal info to optional log.</p></li>
+</ul>
 </blockquote>
 <p>2022-11-19  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>
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.