Skip to content
Permalink
Browse files

https://github.com//issues/1554

  • Loading branch information...
Cristy
Cristy committed Apr 27, 2019
1 parent 3183a88 commit f7206618d27c2e69d977abf40e3035a33e5f6be0
Showing with 5 additions and 3 deletions.
  1. +5 −3 coders/mat.c
@@ -641,6 +641,7 @@ static Image *ReadMATImageV4(const ImageInfo *image_info,Image *image,
Object parser loop.
*/
ldblk=ReadBlobLSBLong(image);
if(EOFBlob(image)) break;
if ((ldblk > 9999) || (ldblk < 0))
break;
HDR.Type[3]=ldblk % 10; ldblk /= 10; /* T digit */
@@ -961,10 +962,10 @@ static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception)
}

filepos = TellBlob(image);
while(!EOFBlob(image)) /* object parser loop */
while(filepos < GetBlobSize(image) && !EOFBlob(image)) /* object parser loop */
{
Frames = 1;
if (filepos != (unsigned int) filepos)
if(filepos > GetBlobSize(image) || filepos < 0)
break;
if(SeekBlob(image,filepos,SEEK_SET) != filepos) break;
/* printf("pos=%X\n",TellBlob(image)); */
@@ -973,7 +974,7 @@ static Image *ReadMATImage(const ImageInfo *image_info,ExceptionInfo *exception)
if(EOFBlob(image)) break;
MATLAB_HDR.ObjectSize = ReadBlobXXXLong(image);
if(EOFBlob(image)) break;
if((MagickSizeType) (MATLAB_HDR.ObjectSize+filepos) > GetBlobSize(image))
if((MagickSizeType) (MATLAB_HDR.ObjectSize+filepos) >= GetBlobSize(image))
goto MATLAB_KO;
filepos += (MagickOffsetType) MATLAB_HDR.ObjectSize + 4 + 4;

@@ -1276,6 +1277,7 @@ RestoreMSCWarning
{
if (logging) (void)LogMagickEvent(CoderEvent,GetMagickModule(),
" MAT cannot read scanrow %u from a file.", (unsigned)(MATLAB_HDR.SizeY-i-1));
ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
goto ExitLoop;
}
if((CellType==miINT8 || CellType==miUINT8) && (MATLAB_HDR.StructureFlag & FLAG_LOGICAL))

0 comments on commit f720661

Please sign in to comment.
You can’t perform that action at this time.