diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 6e39a5f7..35046d81 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -1904,9 +1904,11 @@ vips__istiff_buffer( void *buf, size_t len ) { char *str = (char *) buf; - if( len >= 2 && - ((str[0] == 'M' && str[1] == 'M') || - (str[0] == 'I' && str[1] == 'I')) ) + if( len >= 4 && + ((str[0] == 'M' && str[1] == 'M' && + str[2] == '\0' && (str[3] == '*' || str[3] == '+')) || + (str[0] == 'I' && str[1] == 'I' && + (str[2] == '*' || str[2] == '+') && str[3] == '\0')) ) return( TRUE ); return( FALSE ); @@ -1915,10 +1917,10 @@ vips__istiff_buffer( void *buf, size_t len ) gboolean vips__istiff( const char *filename ) { - unsigned char buf[2]; + unsigned char buf[4]; - if( vips__get_bytes( filename, buf, 2 ) && - vips__istiff_buffer( buf, 2 ) ) + if( vips__get_bytes( filename, buf, 4 ) && + vips__istiff_buffer( buf, 4 ) ) return( TRUE ); return( FALSE );