From ca5add7e8a1811246f53c89913771ac6a9c45901 Mon Sep 17 00:00:00 2001 From: cristy Date: Sat, 4 Apr 2015 23:58:14 +0000 Subject: [PATCH] --- coders/ps3.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/coders/ps3.c b/coders/ps3.c index 6481ba0c6..687ebf347 100644 --- a/coders/ps3.c +++ b/coders/ps3.c @@ -472,11 +472,15 @@ static MagickBooleanType WritePS3MaskImage(const ImageInfo *image_info, Note BeginData DSC comment for update later. */ start=TellBlob(image); + if (start < 0) + ThrowWriterException(CorruptImageError,"ImproperImageHeader"); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%BeginData:%13ld %s Bytes\n",0L,compression == NoCompression ? "ASCII" : "BINARY"); (void) WriteBlobString(image,buffer); stop=TellBlob(image); + if (stop < 0) + ThrowWriterException(CorruptImageError,"ImproperImageHeader"); /* Only lossless compressions for the mask. */ @@ -595,6 +599,8 @@ static MagickBooleanType WritePS3MaskImage(const ImageInfo *image_info, (void) WriteBlobByte(image,'\n'); length=(size_t) (TellBlob(image)-stop); stop=TellBlob(image); + if (stop < 0) + ThrowWriterException(CorruptImageError,"ImproperImageHeader"); offset=SeekBlob(image,start,SEEK_SET); if (offset < 0) ThrowWriterException(CorruptImageError,"ImproperImageHeader"); @@ -1176,11 +1182,15 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, Remember position of BeginData comment so we can update it. */ start=TellBlob(image); + if (start < 0) + ThrowWriterException(CorruptImageError,"ImproperImageHeader"); (void) FormatLocaleString(buffer,MaxTextExtent, "%%%%BeginData:%13ld %s Bytes\n",0L, compression == NoCompression ? "ASCII" : "BINARY"); (void) WriteBlobString(image,buffer); stop=TellBlob(image); + if (stop < 0) + ThrowWriterException(CorruptImageError,"ImproperImageHeader"); (void) WriteBlobString(image,"DisplayImage\n"); /* Translate, scale, and font point size. @@ -1567,6 +1577,8 @@ static MagickBooleanType WritePS3Image(const ImageInfo *image_info,Image *image, */ length=(size_t) (TellBlob(image)-stop); stop=TellBlob(image); + if (stop < 0) + ThrowWriterException(CorruptImageError,"ImproperImageHeader"); offset=SeekBlob(image,start,SEEK_SET); if (offset < 0) ThrowWriterException(CorruptImageError,"ImproperImageHeader"); -- 2.40.0