]> granicus.if.org Git - imagemagick/commitdiff
...
authorCristy <urban-warrior@imagemagick.org>
Wed, 1 Mar 2017 22:41:53 +0000 (17:41 -0500)
committerCristy <urban-warrior@imagemagick.org>
Wed, 1 Mar 2017 22:42:22 +0000 (17:42 -0500)
coders/pnm.c

index 3db8d70a9465c7009c8dbbcb28853830d3ee58fd..9a1221d796bb731b0b273860828b835f6e7ad308 100644 (file)
@@ -429,6 +429,7 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
       Convert PNM pixels to runextent-encoded MIFF packets.
     */
     row=0;
+    y=0;
     switch (format)
     {
       case '1':
@@ -592,12 +593,10 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           size_t
             length;
 
-          if (status == MagickFalse)
-            continue;
           pixels=(unsigned char *) ReadBlobStream(image,extent,
             GetQuantumPixels(quantum_info),&count);
           if (count != (ssize_t) extent)
-            status=MagickFalse;
+            break;
           if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
               (image->previous == (Image *) NULL))
             {
@@ -607,26 +606,21 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
                 row,image->rows);
               if (proceed == MagickFalse)
-                status=MagickFalse;
+                break;
             }
           offset=row++;
           q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
           if (q == (Quantum *) NULL)
-            {
-              status=MagickFalse;
-              continue;
-            }
+            break;
           length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
             quantum_type,pixels,exception);
           if (length != extent)
-            status=MagickFalse;
+            break;
           sync=SyncAuthenticPixels(image,exception);
           if (sync == MagickFalse)
-            status=MagickFalse;
+            break;
         }
         quantum_info=DestroyQuantumInfo(quantum_info);
-        if (status == MagickFalse)
-          ThrowReaderException(CorruptImageError,"UnableToReadImageData");
         SetQuantumImageType(image,quantum_type);
         break;
       }
@@ -668,12 +662,10 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             count,
             offset;
 
-          if (status == MagickFalse)
-            continue;
           pixels=(unsigned char *) ReadBlobStream(image,extent,
             GetQuantumPixels(quantum_info),&count);
           if (count != (ssize_t) extent)
-            status=MagickFalse;
+            break;
           if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
               (image->previous == (Image *) NULL))
             {
@@ -683,15 +675,12 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
                 row,image->rows);
               if (proceed == MagickFalse)
-                status=MagickFalse;
+                break;
             }
           offset=row++;
           q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
           if (q == (Quantum *) NULL)
-            {
-              status=MagickFalse;
-              continue;
-            }
+            break;
           p=pixels;
           switch (image->depth)
           {
@@ -745,11 +734,9 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
           sync=SyncAuthenticPixels(image,exception);
           if (sync == MagickFalse)
-            status=MagickFalse;
+            break;
         }
         quantum_info=DestroyQuantumInfo(quantum_info);
-        if (status == MagickFalse)
-          ThrowReaderException(CorruptImageError,"UnableToReadImageData");
         SetQuantumImageType(image,quantum_type);
         break;
       }
@@ -785,12 +772,10 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             count,
             offset;
 
-          if (status == MagickFalse)
-            continue;
           pixels=(unsigned char *) ReadBlobStream(image,extent,
             GetQuantumPixels(quantum_info),&count);
           if (count != (ssize_t) extent)
-            status=MagickFalse;
+            break;
           if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
               (image->previous == (Image *) NULL))
             {
@@ -800,15 +785,12 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
                 row,image->rows);
               if (proceed == MagickFalse)
-                status=MagickFalse;
+                break;
             }
           offset=row++;
           q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
           if (q == (Quantum *) NULL)
-            {
-              status=MagickFalse;
-              continue;
-            }
+            break;
           p=pixels;
           switch (image->depth)
           {
@@ -917,11 +899,9 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
           sync=SyncAuthenticPixels(image,exception);
           if (sync == MagickFalse)
-            status=MagickFalse;
+            break;
         }
         quantum_info=DestroyQuantumInfo(quantum_info);
-        if (status == MagickFalse)
-          ThrowReaderException(CorruptImageError,"UnableToReadImageData");
         break;
       }
       case '7':
@@ -985,12 +965,10 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
             count,
             offset;
 
-          if (status == MagickFalse)
-            continue;
           pixels=(unsigned char *) ReadBlobStream(image,extent,
             GetQuantumPixels(quantum_info),&count);
           if (count != (ssize_t) extent)
-            status=MagickFalse;
+            break;
           if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
               (image->previous == (Image *) NULL))
             {
@@ -1000,15 +978,12 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
                 row,image->rows);
               if (proceed == MagickFalse)
-                status=MagickFalse;
+                break;
             }
           offset=row++;
           q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
           if (q == (Quantum *) NULL)
-            {
-              status=MagickFalse;
-              continue;
-            }
+            break;
           p=pixels;
           switch (image->depth)
           {
@@ -1256,11 +1231,9 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           }
           sync=SyncAuthenticPixels(image,exception);
           if (sync == MagickFalse)
-            status=MagickFalse;
+            break;
         }
         quantum_info=DestroyQuantumInfo(quantum_info);
-        if (status == MagickFalse)
-          ThrowReaderException(CorruptImageError,"UnableToReadImageData");
         SetQuantumImageType(image,quantum_type);
         break;
       }
@@ -1304,12 +1277,10 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
           size_t
             length;
 
-          if (status == MagickFalse)
-            continue;
           pixels=(unsigned char *) ReadBlobStream(image,extent,
             GetQuantumPixels(quantum_info),&count);
           if ((size_t) count != extent)
-            status=MagickFalse;
+            break;
           if ((image->progress_monitor != (MagickProgressMonitor) NULL) &&
               (image->previous == (Image *) NULL))
             {
@@ -1319,33 +1290,30 @@ static Image *ReadPNMImage(const ImageInfo *image_info,ExceptionInfo *exception)
               proceed=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
                 row,image->rows);
               if (proceed == MagickFalse)
-                status=MagickFalse;
+                break;
             }
           offset=row++;
           q=QueueAuthenticPixels(image,0,(ssize_t) (image->rows-offset-1),
             image->columns,1,exception);
           if (q == (Quantum *) NULL)
-            {
-              status=MagickFalse;
-              continue;
-            }
+            break;
           length=ImportQuantumPixels(image,(CacheView *) NULL,quantum_info,
             quantum_type,pixels,exception);
           if (length != extent)
-            status=MagickFalse;
+            break;
           sync=SyncAuthenticPixels(image,exception);
           if (sync == MagickFalse)
-            status=MagickFalse;
+            break;
         }
         quantum_info=DestroyQuantumInfo(quantum_info);
-        if (status == MagickFalse)
-          ThrowReaderException(CorruptImageError,"UnableToReadImageData");
         SetQuantumImageType(image,quantum_type);
         break;
       }
       default:
         ThrowReaderException(CorruptImageError,"ImproperImageHeader");
     }
+    if (y < (ssize_t) image->rows)
+      ThrowReaderException(CorruptImageError,"UnableToReadImageData");
     if (EOFBlob(image) != MagickFalse)
       {
         (void) ThrowMagickException(exception,GetMagickModule(),