From d0eb5833a5325ce92730d36e6e6aa114a6958a9a Mon Sep 17 00:00:00 2001 From: Cristy Date: Wed, 1 Mar 2017 17:41:53 -0500 Subject: [PATCH] ... --- coders/pnm.c | 82 ++++++++++++++++------------------------------------ 1 file changed, 25 insertions(+), 57 deletions(-) diff --git a/coders/pnm.c b/coders/pnm.c index 3db8d70a9..9a1221d79 100644 --- a/coders/pnm.c +++ b/coders/pnm.c @@ -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(), -- 2.40.0