diff --git a/ChangeLog b/ChangeLog index 9575253c..08cfbe09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/libvips/iofuncs/source.c b/libvips/iofuncs/source.c index 3c286007..994caa9e 100644 --- a/libvips/iofuncs/source.c +++ b/libvips/iofuncs/source.c @@ -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 ); diff --git a/libvips/iofuncs/util.c b/libvips/iofuncs/util.c index 48001ed6..09ef6757 100644 --- a/libvips/iofuncs/util.c +++ b/libvips/iofuncs/util.c @@ -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*/