detect read errors in sniff correctly

we has a signed/unsigned mixup :(
This commit is contained in:
John Cupitt 2020-03-05 15:02:16 +00:00
parent 6a2fbbaed7
commit b3a7929247
3 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@
- better gifload behaviour for DISPOSAL_UNSPECIFIED [DarthSim]
- ban ppm max_value < 0
- add fuzz corpus to dist
- detect read errors correctly in source_sniff
20/6/19 started 8.9.1
- don't use the new source loaders for new_from_file or new_from_buffer, it

View File

@ -1153,7 +1153,7 @@ vips_source_length( VipsSource *source )
}
/**
* vips_source_peek:
* vips_source_sniff_at_most:
* @source: peek this source
* @data: return a pointer to the bytes read here
* @length: max number of bytes to read
@ -1219,13 +1219,13 @@ unsigned char *
vips_source_sniff( VipsSource *source, size_t length )
{
unsigned char *data;
size_t bytes_read;
gint64 bytes_read;
if( vips_source_test_features( source ) )
return( NULL );
bytes_read = vips_source_sniff_at_most( source, &data, length );
if( bytes_read < length )
if( bytes_read < (gint64) length )
return( NULL );
return( data );

View File

@ -1036,6 +1036,10 @@ vips__seek_no_error( int fd, gint64 pos, int whence )
#ifdef OS_WIN32
new_pos = _lseeki64( fd, pos, whence );
#else /*!OS_WIN32*/
/* On error, eg. opening a directory and seeking to the end, lseek()
* on linux seems to return 9223372036854775807 ((1 << 63) - 1)
* rather than (off_t) -1 for reasons I don't understand.
*/
new_pos = lseek( fd, pos, whence );
#endif /*OS_WIN32*/