From: Cristy Date: Fri, 22 Feb 2019 00:59:11 +0000 (-0500) Subject: ... X-Git-Tag: 7.0.8-29~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2506070875222aa5084164b7339357d09d72a358;p=imagemagick ... --- diff --git a/coders/miff.c b/coders/miff.c index 8f6f6b3b4..0de54fb94 100644 --- a/coders/miff.c +++ b/coders/miff.c @@ -1140,28 +1140,30 @@ static Image *ReadMIFFImage(const ImageInfo *image_info, /* Image directory. */ - length=MagickPathExtent; + extent=MagickPathExtent; image->directory=AcquireString((char *) NULL); p=image->directory; + length=0; do { *p='\0'; - if ((strlen(image->directory)+MagickPathExtent) >= length) + if ((length+MagickPathExtent) >= extent) { /* Allocate more memory for the image directory. */ - length<<=1; + extent<<=1; image->directory=(char *) ResizeQuantumMemory(image->directory, - length+MagickPathExtent,sizeof(*image->directory)); + extent+MagickPathExtent,sizeof(*image->directory)); if (image->directory == (char *) NULL) ThrowMIFFException(CorruptImageError,"UnableToReadImageData"); - p=image->directory+strlen(image->directory); + p=image->directory+length; } c=ReadBlobByte(image); if (c == EOF) break; *p++=(char) c; + length++; } while (c != (int) '\0'); } if (profiles != (LinkedListInfo *) NULL) diff --git a/coders/mpc.c b/coders/mpc.c index 5ebea0645..35df8af89 100644 --- a/coders/mpc.c +++ b/coders/mpc.c @@ -179,6 +179,7 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) size_t depth, + extent, length; ssize_t @@ -809,20 +810,21 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) /* Image directory. */ - length=MagickPathExtent; + extent=MagickPathExtent; image->directory=AcquireString((char *) NULL); p=image->directory; + length=0; do { *p='\0'; - if ((strlen(image->directory)+MagickPathExtent) >= length) + if ((length+MagickPathExtent) >= extent) { /* Allocate more memory for the image directory. */ - length<<=1; + extent<<=1; image->directory=(char *) ResizeQuantumMemory(image->directory, - length+MagickPathExtent,sizeof(*image->directory)); + extent+MagickPathExtent,sizeof(*image->directory)); if (image->directory == (char *) NULL) { if (profiles != (LinkedListInfo *) NULL) @@ -830,12 +832,13 @@ static Image *ReadMPCImage(const ImageInfo *image_info,ExceptionInfo *exception) ThrowReaderException(CorruptImageError, "UnableToReadImageData"); } - p=image->directory+strlen(image->directory); + p=image->directory+length; } c=ReadBlobByte(image); if (c == EOF) break; *p++=(char) c; + length++; } while (c != (int) '\0'); } if (profiles != (LinkedListInfo *) NULL)