[prev in list] [next in list] [prev in thread] [next in thread] 

List:       graphicsmagick-commit
Subject:    [GM-commit] GraphicsMagick: Fix minor Coverity gripes.
From:       GraphicsMagick Commits <graphicsmagick-commit () lists ! sourceforge ! net>
Date:       2018-09-09 19:32:34
Message-ID: mailman.10000.1536521563.1387.graphicsmagick-commit () lists ! sourceforge ! net
[Download RAW message or body]

changeset d6035da9dc0d in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=d6035da9dc0d
                
summary: Fix minor Coverity gripes.

diffstat:

 ChangeLog          |   6 +++++
 coders/wpg.c       |  63 ++++++++++++++++++++++++++++-------------------------
 magick/render.c    |   3 +-
 www/Changelog.html |   4 +++
 4 files changed, 44 insertions(+), 32 deletions(-)

diffs (189 lines):

diff -r f6aab6087677 -r d6035da9dc0d ChangeLog
--- a/ChangeLog	Sun Sep 09 13:00:14 2018 -0500
+++ b/ChangeLog	Sun Sep 09 14:32:32 2018 -0500
@@ -1,5 +1,11 @@
 2018-09-09  Bob Friesenhahn  <bfriesen@simple.dallas.tx.us>
 
+	* magick/render.c (DrawClipPath): Fix Coverity 319663 "Null
+	pointer dereferences".  Totally insignificant.
+
+	* coders/wpg.c (ReadWPGImage): Mask/fix Coverity 319664 "Error
+	handling issues".
+
 	* magick/attribute.c (FindEXIFAttribute): Change size types from
 	signed to unsigned and check for unsigned overflow.
 	(GenerateEXIFAttribute): Change size types from signed to unsigned
diff -r f6aab6087677 -r d6035da9dc0d coders/wpg.c
--- a/coders/wpg.c	Sun Sep 09 13:00:14 2018 -0500
+++ b/coders/wpg.c	Sun Sep 09 14:32:32 2018 -0500
@@ -392,13 +392,14 @@
 
 /** Call this function to ensure that all data matrix is filled with something. This \
                function
  * is used only to error recovery. */
-static void ZeroFillMissingData(unsigned char *BImgBuff,unsigned long x, unsigned \
                long y, Image *image, 
-			 int bpp, long ldblk)
+static void ZeroFillMissingData(unsigned char *BImgBuff,unsigned long x, unsigned \
long y, Image *image, +                                int bpp, long ldblk)
 {
   while(y < image->rows)
   {
-    if(x<ldblk) memset(BImgBuff+x, 0, ldblk-x);
-    InsertRow(BImgBuff,y,image,bpp);
+    if((long) x<ldblk) memset(BImgBuff+x, 0, ldblk-(long)x);
+    if (InsertRow(BImgBuff,y,image,bpp) == MagickFail)
+      break;
     x = 0;
     y++;
   }
@@ -442,7 +443,7 @@
       i = ReadBlobByte(image);
       if(i==EOF)
         {
-	  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+          ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
           MagickFreeMemory(BImgBuff);
           return(-5);
         }
@@ -474,32 +475,34 @@
           i = ReadBlobByte(image);
           if(i==EOF)
           {
-	    ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+            ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
             MagickFreeMemory(BImgBuff);
             return -7;
           }
           RunCount = i;
           if(x!=0) {    /* attempt to duplicate row from x position: */
                         /* I do not know what to do here */
-            InsertRow(BImgBuff,y,image,bpp);   /* May be line flush can fix a \
                situation. */
-            x=0;
-            y++;
-	    ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+            if (InsertRow(BImgBuff,y,image,bpp) == MagickPass)   /* May be line \
flush can fix a situation. */ +              {
+                x=0;
+                y++;
+                ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+              }
             MagickFreeMemory(BImgBuff);
             return(-3);
           }
           for(i=0; i<(int)RunCount; i++)
-            {		/* Here I need to duplicate previous row RUNCOUNT* */
-			/* when x=0; y points to a new empty line. For y=0 zero line will be populated. \
*/ +            {           /* Here I need to duplicate previous row RUNCOUNT* */
+                        /* when x=0; y points to a new empty line. For y=0 zero line \
will be populated. */  if(y>=image->rows)
                 {
-		  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+                  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
                   MagickFreeMemory(BImgBuff);
                   return(-4);
                 }
               if(InsertRow(BImgBuff,y,image,bpp)==MagickFail)
                 {
-		  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
+                  ZeroFillMissingData(BImgBuff,x,y,image,bpp,ldblk);
                   MagickFreeMemory(BImgBuff);
                   return(-6);
                 }
@@ -1108,10 +1111,10 @@
   if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
           "File type: %d", Header.FileType);
 
-	/* Determine file size. */
-  filesize = GetBlobSize(image);	      /* zero is returned if the size cannot be \
determined. */ +        /* Determine file size. */
+  filesize = GetBlobSize(image);              /* zero is returned if the size cannot \
be determined. */  if(filesize>0 && BlobIsSeekable(image))
-  { 
+  {
     if(filesize > (magick_off_t)0xFFFFFFFF)
         filesize = (magick_off_t)0xFFFFFFFF;  /* More than 4GiB are not supported in \
MAT! */  }
@@ -1131,29 +1134,29 @@
       while(!EOFBlob(image)) /* object parser loop */
         {
           if(SeekBlob(image,FilePos,SEEK_SET) != FilePos)
-            break;          
+            break;
 
           Rec.RecType = (i=ReadBlobByte(image));
           if(i==EOF) break;
-	  FilePos += 1;
+          FilePos += 1;
 
           FilePos += Rd_WP_DWORD(image,&Rec.RecordLength);
           if((magick_off_t)Rec.RecordLength > filesize)
             ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
           if(EOFBlob(image)) break;
-	  
-	  FilePos += (magick_off_t)Rec.RecordLength;
+
+          FilePos += (magick_off_t)Rec.RecordLength;
           if(FilePos>filesize || FilePos<Header.DataOffset)
-	  {
+          {
             if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
                 "Invalid record length: %X", (unsigned)Rec.RecType);
-	    break;
-	  }
+            break;
+          }
           Header.DataOffset = FilePos;
 
           if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
             "Parsing object: %X", Rec.RecType);
-	  //printf("\nParsing object: %u:%X", (unsigned)FilePos, Rec.RecType);
+          //printf("\nParsing object: %u:%X", (unsigned)FilePos, Rec.RecType);
 
           switch(Rec.RecType)
             {
@@ -1267,14 +1270,14 @@
               if(bpp == 1)
                 {
                   if(image->colors<=0)
-				  {
-			        image->colormap[0].red =
+                                  {
+                                image->colormap[0].red =
                         image->colormap[0].green =
                         image->colormap[0].blue = 0;
                       image->colormap[0].opacity = OpaqueOpacity;
-				  }
-                  if(image->colors<=1 ||	/* Realloc has been enforced and value [1] \
                remains uninitialised, or .. */
-					   (image->colormap[0].red==0 && image->colormap[0].green==0 && \
image->colormap[0].blue==0 && +                                  }
+                  if(image->colors<=1 ||        /* Realloc has been enforced and \
value [1] remains uninitialised, or .. */ +                                           \
(image->colormap[0].red==0 && image->colormap[0].green==0 && \
                image->colormap[0].blue==0 &&
                         image->colormap[1].red==0 && image->colormap[1].green==0 && \
image->colormap[1].blue==0))  {  /* fix crippled monochrome palette */
                       image->colormap[1].red =
diff -r f6aab6087677 -r d6035da9dc0d magick/render.c
--- a/magick/render.c	Sun Sep 09 13:00:14 2018 -0500
+++ b/magick/render.c	Sun Sep 09 14:32:32 2018 -0500
@@ -1743,8 +1743,7 @@
       clone_info->opacity = OpaqueOpacity;  /* SVG default */
     }
 
-  if (clone_info != (DrawInfo *) NULL)
-    MagickFreeMemory(clone_info->extra->clip_path);
+  MagickFreeMemory(clone_info->extra->clip_path);
   if ((status=DrawImage(image_clip_mask,clone_info)) == MagickFail)
     goto draw_clip_path_end;
   if ((status=NegateImage(image_clip_mask,False)) == MagickFail)
diff -r f6aab6087677 -r d6035da9dc0d www/Changelog.html
--- a/www/Changelog.html	Sun Sep 09 13:00:14 2018 -0500
+++ b/www/Changelog.html	Sun Sep 09 14:32:32 2018 -0500
@@ -38,6 +38,10 @@
 <p>2018-09-09  Bob Friesenhahn  &lt;<a class="reference external" \
href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#6 \
4;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
  <blockquote>
 <ul class="simple">
+<li>magick/render.c (DrawClipPath): Fix Coverity 319663 &quot;Null
+pointer dereferences&quot;.  Totally insignificant.</li>
+<li>coders/wpg.c (ReadWPGImage): Mask/fix Coverity 319664 &quot;Error
+handling issues&quot;.</li>
 <li>magick/attribute.c (FindEXIFAttribute): Change size types from
 signed to unsigned and check for unsigned overflow.
 (GenerateEXIFAttribute): Change size types from signed to unsigned


_______________________________________________
Graphicsmagick-commit mailing list
Graphicsmagick-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/graphicsmagick-commit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic