fix a possible read loop for truncated gifs

This commit is contained in:
John Cupitt 2020-11-20 13:46:24 +00:00
parent d971c75d6f
commit 1e5ac06f84
1 changed files with 4 additions and 2 deletions

View File

@ -367,9 +367,11 @@ vips_giflib_read( GifFileType *file, GifByteType *buf, int n )
gint64 bytes_read;
bytes_read = vips_source_read( gif->source, buf, n );
if( bytes_read == 0 )
if( bytes_read == 0 ) {
gif->eof = TRUE;
if( bytes_read <= 0 )
return( -1 );
}
if( bytes_read < 0 )
return( -1 );
if( bytes_read > INT_MAX )
return( -1 );