From: Cristy Date: Sat, 3 Feb 2018 18:51:02 +0000 (-0500) Subject: ... X-Git-Tag: 7.0.7-23~160 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=66595914939217f5f08639801c98c1a3f351c411;p=imagemagick ... --- diff --git a/MagickCore/blob.c b/MagickCore/blob.c index 2bb35466a..cb0465917 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -118,6 +118,9 @@ struct _BlobInfo extent, quantum; + BlobMode + mode; + MagickBooleanType mapped, eof; @@ -653,6 +656,7 @@ MagickExport MagickBooleanType CloseBlob(Image *image) blob_info->size=GetBlobSize(image); image->extent=blob_info->size; blob_info->eof=MagickFalse; + blob_info->mode=UndefinedBlobMode; if (blob_info->exempt != MagickFalse) { blob_info->type=UndefinedStream; @@ -3063,6 +3067,7 @@ MagickExport MagickBooleanType OpenBlob(const ImageInfo *image_info, return(MagickTrue); } (void) DetachBlob(blob_info); + blob_info->mode=mode; switch (mode) { default: type="r"; break; @@ -4698,14 +4703,30 @@ MagickExport MagickOffsetType SeekBlob(Image *image, break; } } - if (blob_info->offset < (MagickOffsetType) ((off_t) blob_info->length)) + if (blob_info->offset <= (MagickOffsetType) ((off_t) blob_info->length)) { blob_info->eof=MagickFalse; break; } - if (blob_info->offset < (MagickOffsetType) ((off_t) blob_info->extent)) - break; - return(-1); + if ((image->blob->mapped == MagickFalse) && + ((image->blob->mode == WriteBlobMode) || + (image->blob->mode == WriteBinaryBlobMode))) + { + image->blob->extent=(size_t) (image->blob->offset+ + image->blob->quantum); + image->blob->quantum<<=1; + image->blob->data=(unsigned char *) ResizeQuantumMemory( + image->blob->data,image->blob->extent+1,sizeof(*image->blob->data)); + (void) SyncBlob(image); + if (image->blob->data == (unsigned char *) NULL) + { + (void) DetachBlob(image->blob); + return(-1); + } + } + if (blob_info->offset > (MagickOffsetType) ((off_t) blob_info->extent)) + return(-1); + break; } case CustomStream: {