diff --git a/ChangeLog b/ChangeLog index 298c9fab..49a599cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,6 +19,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 diff --git a/libvips/iofuncs/source.c b/libvips/iofuncs/source.c index af482d11..8fa06b5f 100644 --- a/libvips/iofuncs/source.c +++ b/libvips/iofuncs/source.c @@ -1191,7 +1191,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 @@ -1257,13 +1257,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 ); diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 2399485d..3fd9ddf3 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -1090,6 +1090,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*/