From: Dirk Lemstra Date: Thu, 11 May 2017 20:45:43 +0000 (+0200) Subject: Added check to make sure the correct number of bytes could be read. X-Git-Tag: 7.0.5-6~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b1c7cd70cc7ae88f179cb060f75ccd6821c33ce6;p=imagemagick Added check to make sure the correct number of bytes could be read. --- diff --git a/coders/psd.c b/coders/psd.c index 2bc0cccf8..4799f9b4a 100644 --- a/coders/psd.c +++ b/coders/psd.c @@ -1204,11 +1204,14 @@ static MagickBooleanType ReadPSDChannelZip(Image *image,const size_t channels, ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); } - + if (ReadBlob(image,compact_size,compact_pixels) != (ssize_t) compact_size) + { + compact_pixels=(unsigned char *) RelinquishMagickMemory(compact_pixels); + ThrowBinaryException(CorruptImageError,"UnexpectedEndOfFile", + image->filename); + } ResetMagickMemory(&stream,0,sizeof(stream)); stream.data_type=Z_BINARY; - (void) ReadBlob(image,compact_size,compact_pixels); - stream.next_in=(Bytef *)compact_pixels; stream.avail_in=(uInt) compact_size; stream.next_out=(Bytef *)pixels;