GraphicsMagick: FPX: Coverity fixes for "dead code" and an integ...

GraphicsMagick Commits <[email protected]> Sat, 24 Aug 2024 18:05:10 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.15853.1724540723.1470.graphicsmagick-commit@lists.sourceforge.net>
changeset b050371e0759 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=b050371e0759
summary: FPX: Coverity fixes for "dead code" and an integer overflow issue.

diffstat:

 ChangeLog          |  3 +++
 coders/fpx.c       |  8 +++++++-
 magick/image.c     |  2 +-
 www/ChangeLog.html |  2 ++
 4 files changed, 13 insertions(+), 2 deletions(-)

diffs (89 lines):

diff -r f487bf6d8a4d -r b050371e0759 ChangeLog
--- a/ChangeLog	Sat Aug 24 15:45:08 2024 -0500
+++ b/ChangeLog	Sat Aug 24 18:04:26 2024 -0500
@@ -1,5 +1,8 @@
 2024-08-24  Bob Friesenhahn  <[email protected]>
 
+	* coders/fpx.c: Coverity fixes for "dead code" and an integer
+	overflow issue.
+
 	* magick/image.c (MagickParseSubImageSpecification): Fix
 	SourceForge issue "#746 Off-by-one-error when converting PDF with
 	multiple pages". Also add additional sanity checking.
diff -r f487bf6d8a4d -r b050371e0759 coders/fpx.c
--- a/coders/fpx.c	Sat Aug 24 15:45:08 2024 -0500
+++ b/coders/fpx.c	Sat Aug 24 18:04:26 2024 -0500
@@ -63,6 +63,7 @@
 #    include "Fpxlib.h"
 #  endif
 #endif
+#define DEAD_CODE 0
 
 /*
   Forward declarations.
@@ -446,7 +447,8 @@
     {
       width>>=1;
       height>>=1;
-      subimage--;
+      if (subimage != 0)
+        subimage--;
     }
   image->depth=8;
   image->columns=width;
@@ -693,6 +695,7 @@
 %
 */
 
+#if DEAD_CODE
 static void ColorTwistMultiply(FPXColorTwistMatrix first,
   FPXColorTwistMatrix second,FPXColorTwistMatrix *color_twist)
 {
@@ -873,6 +876,7 @@
   ColorTwistMultiply(*color_twist,effect,&result);
   *color_twist=result;
 }
+#endif /* if DEAD_CODE */
 
 static unsigned int WriteFPXImage(const ImageInfo *image_info,Image *image)
 {
@@ -1076,6 +1080,7 @@
                                   image->columns,image->rows))
         break;
   }
+#if DEAD_CODE /* Obviously not finished with implementation since does nothing */
   if (image_info->view != (char *) NULL)
     {
       FPXAffineMatrix
@@ -1201,6 +1206,7 @@
               image);
         }
     }
+#endif /* if DEAD_CODE */
   (void) FPX_CloseImage(flashpix);
   FPX_ClearSystem();
   MagickFreeResourceLimitedMemory(pixels);
diff -r f487bf6d8a4d -r b050371e0759 magick/image.c
--- a/magick/image.c	Sat Aug 24 15:45:08 2024 -0500
+++ b/magick/image.c	Sat Aug 24 18:04:26 2024 -0500
@@ -2903,7 +2903,7 @@
         }
       if ((status != MagickFail) && (*q == '\0'))
         {
-          subrange -= (long)subimage-1;
+          subrange -= subimage-1; /* Coverity 427451 Overflowed constant (when subimage=0) */
           *subimage_ptr=subimage;
           *subrange_ptr=subrange;
           status=MagickPass;
diff -r f487bf6d8a4d -r b050371e0759 www/ChangeLog.html
--- a/www/ChangeLog.html	Sat Aug 24 15:45:08 2024 -0500
+++ b/www/ChangeLog.html	Sat Aug 24 18:04:26 2024 -0500
@@ -41,6 +41,8 @@
 <p>2024-08-24  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/fpx.c: Coverity fixes for &quot;dead code&quot; and an integer
+overflow issue.</p></li>
 <li><p>magick/image.c (MagickParseSubImageSpecification): Fix
 SourceForge issue &quot;#746 Off-by-one-error when converting PDF with
 multiple pages&quot;. Also add additional sanity checking.