]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Tue, 30 Dec 2014 23:48:22 +0000 (23:48 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Tue, 30 Dec 2014 23:48:22 +0000 (23:48 +0000)
coders/meta.c
coders/pcx.c
coders/pdb.c

index 5f9c5f7d6c9615c64f367397d259a7efe711866a..385093b0e990aee2f027f4bd5473bd4a49be00e9 100644 (file)
@@ -213,7 +213,7 @@ static int convertHTMLcodes(char *s, int len)
             break;
         }
         if (o < 6)
-          (void) strcpy(s+1,s+1+o);
+          (void) memmove(s+1,s+1+o,strlen(s+1+o)+1);
         *s = val;
         return o;
       }
@@ -229,8 +229,9 @@ static int convertHTMLcodes(char *s, int len)
         if (html_codes[i].len <= len)
           if (stringnicmp(s,html_codes[i].code,(size_t) html_codes[i].len) == 0)
             {
-              (void) strcpy(s+1,s+html_codes[i].len);
-              *s = html_codes[i].val;
+              (void) memmove(s+1,s+html_codes[i].len,
+                strlen(s+html_codes[i].len)+1);
+              *s=html_codes[i].val;
               return html_codes[i].len-1;
             }
       }
index 57fcb1758e01b5dfc6cab5b5057bc0aa8eb5d4a0..e580bad8875aabfd604b5607d6da7d0fa24f5ce0 100644 (file)
@@ -89,7 +89,9 @@ typedef struct _PCXInfo
 
   unsigned short
     bytes_per_line,
-    palette_info;
+    palette_info,
+    horizontal_screensize,
+    vertical_screensize;
 
   unsigned char
     colormap_signature;
@@ -313,7 +315,7 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
       Verify PCX identifier.
     */
     pcx_info.version=(unsigned char) ReadBlobByte(image);
-    if ((count == 0) || (pcx_info.identifier != 0x0a))
+    if ((count != 1) || (pcx_info.identifier != 0x0a))
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
     pcx_info.encoding=(unsigned char) ReadBlobByte(image);
     bits_per_pixel=ReadBlobByte(image);
@@ -334,14 +336,19 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     image->rows=(size_t) MagickAbsoluteValue((ssize_t) pcx_info.bottom-
       pcx_info.top)+1UL;
     if ((image->columns == 0) || (image->rows == 0) ||
-        (pcx_info.bits_per_pixel == 0))
+        ((pcx_info.bits_per_pixel != 1) &&
+         (pcx_info.bits_per_pixel != 2) &&
+         (pcx_info.bits_per_pixel != 4) &&
+         (pcx_info.bits_per_pixel != 8)))
       ThrowReaderException(CorruptImageError,"ImproperImageHeader");
-    image->depth=pcx_info.bits_per_pixel <= 8 ? 8U : MAGICKCORE_QUANTUM_DEPTH;
+    image->depth=pcx_info.bits_per_pixel;
     image->units=PixelsPerInchResolution;
     image->resolution.x=(double) pcx_info.horizontal_resolution;
     image->resolution.y=(double) pcx_info.vertical_resolution;
     image->colors=16;
     count=ReadBlob(image,3*image->colors,pcx_colormap);
+    if (count != (3*image->colors))
+      ThrowReaderException(CorruptImageError,"ImproperImageHeader");
     pcx_info.reserved=(unsigned char) ReadBlobByte(image);
     pcx_info.planes=(unsigned char) ReadBlobByte(image);
     if ((pcx_info.bits_per_pixel*pcx_info.planes) >= 64)
@@ -365,7 +372,9 @@ static Image *ReadPCXImage(const ImageInfo *image_info,ExceptionInfo *exception)
     }
     pcx_info.bytes_per_line=ReadBlobLSBShort(image);
     pcx_info.palette_info=ReadBlobLSBShort(image);
-    for (i=0; i < 58; i++)
+    pcx_info.horizontal_screensize=ReadBlobLSBShort(image);
+    pcx_info.vertical_screensize=ReadBlobLSBShort(image);
+    for (i=0; i < 54; i++)
       (void) ReadBlobByte(image);
     if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
       if (image->scene >= (image_info->scene+image_info->number_scenes-1))
index 36d3a9b1c5b4ded7f5eb11976491dcc001dbf27d..75224a922efb38db73eb6b1dcb9ee1841d57ee49 100644 (file)
@@ -472,7 +472,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (Quantum *) NULL)
           break;
-        for (x=0; x < (ssize_t) image->columns; x+=4)
+        for (x=0; x < (ssize_t) image->columns-3; x+=4)
         {
           index=ConstrainColormapIndex(image,3UL-((*p >> 6) & 0x03),exception);
           SetPixelIndex(image,index,q);
@@ -508,7 +508,7 @@ static Image *ReadPDBImage(const ImageInfo *image_info,ExceptionInfo *exception)
         q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
         if (q == (Quantum *) NULL)
           break;
-        for (x=0; x < (ssize_t) image->columns; x+=2)
+        for (x=0; x < (ssize_t) image->columns-1; x+=2)
         {
           index=ConstrainColormapIndex(image,15UL-((*p >> 4) & 0x0f),exception);
           SetPixelIndex(image,index,q);