From: Cristy Date: Sat, 2 Sep 2017 18:56:59 +0000 (-0400) Subject: Check for EOF X-Git-Tag: 7.0.7-0~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=852ecb0b7fabad6ef90b2cf1eb27f2791e386185;p=imagemagick Check for EOF --- diff --git a/coders/jnx.c b/coders/jnx.c index 4fe7c5992..bb9674b12 100644 --- a/coders/jnx.c +++ b/coders/jnx.c @@ -38,10 +38,6 @@ /* Include declarations. */ - -/* - Include declarations. -*/ #include "MagickCore/studio.h" #include "MagickCore/blob.h" #include "MagickCore/blob-private.h" @@ -190,6 +186,8 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception) else if (jnx_info.version == 3) jnx_info.order=30; + if (EOFBlob(image) != MagickFalse) + ThrowReaderException(CorruptImageError,"ImproperImageHeader"); /* Read JNX levels. */ @@ -201,6 +199,7 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); jnx_level_info[i].offset=ReadBlobLSBSignedLong(image); jnx_level_info[i].scale=ReadBlobLSBLong(image); + *jnx_level_info[i].copyright='\0'; if (jnx_info.version > 3) { register ssize_t @@ -214,8 +213,10 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception) while ((c=ReadBlobLSBShort(image)) != 0) if (j < (MagickPathExtent-1)) jnx_level_info[i].copyright[j++]=c; - jnx_level_info[i].copyright[j]=0; + jnx_level_info[i].copyright[j]='\0'; } + if (EOFBlob(image) != MagickFalse) + ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); } /* Read JNX tiles. @@ -265,6 +266,8 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception) southwest.y=180.0*ReadBlobLSBSignedLong(image)/0x7fffffff; (void) ReadBlobLSBShort(image); /* width */ (void) ReadBlobLSBShort(image); /* height */ + if (EOFBlob(image) != MagickFalse) + ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile"); tile_length=ReadBlobLSBLong(image); tile_offset=ReadBlobLSBSignedLong(image); if (tile_offset == -1) @@ -304,7 +307,8 @@ static Image *ReadJNXImage(const ImageInfo *image_info,ExceptionInfo *exception) offset=SeekBlob(image,restore_offset,SEEK_SET); if (tile_image == (Image *) NULL) continue; - (void) CopyMagickString(tile_image->magick,image->magick,MagickPathExtent); + (void) CopyMagickString(tile_image->magick,image->magick, + MagickPathExtent); (void) FormatImageProperty(tile_image,"jnx:northeast","%.20g,%.20g", northeast.x,northeast.y); (void) FormatImageProperty(tile_image,"jnx:southwest","%.20g,%.20g",