From: Cristy Date: Tue, 26 Jun 2018 23:25:49 +0000 (-0400) Subject: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9109 X-Git-Tag: 7.0.8-4~13 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6aa082fa1f62aaa183d5be90fe05383ab6c4efc7;p=imagemagick https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=9109 --- diff --git a/MagickCore/blob.c b/MagickCore/blob.c index f5caebe51..8a6b1632e 100644 --- a/MagickCore/blob.c +++ b/MagickCore/blob.c @@ -1358,6 +1358,9 @@ MagickExport void *FileToBlob(const char *filename,const size_t extent, int file; + MagickBooleanType + status; + MagickOffsetType offset; @@ -1367,6 +1370,9 @@ MagickExport void *FileToBlob(const char *filename,const size_t extent, ssize_t count; + struct stat + attributes; + unsigned char *blob; @@ -1377,6 +1383,12 @@ MagickExport void *FileToBlob(const char *filename,const size_t extent, (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); assert(exception != (ExceptionInfo *) NULL); *length=0; + status=GetPathAttributes(filename,&attributes); + if ((status == MagickFalse) || (S_ISDIR(attributes.st_mode) != 0)) + { + ThrowFileException(exception,BlobError,"UnableToReadBlob",filename); + return(NULL); + } file=fileno(stdin); if (LocaleCompare(filename,"-") != 0) file=open_utf8(filename,O_RDONLY | O_BINARY,0);