From 7d94e81b7b26dc34f03d10066b3528759361e7ef Mon Sep 17 00:00:00 2001 From: Lovell Fuller Date: Mon, 13 Oct 2014 11:40:28 +0100 Subject: [PATCH] Verify first 4 bytes of TIFF file Avoids Olympus Raw (ORF) false positive --- libvips/foreign/tiff2vips.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libvips/foreign/tiff2vips.c b/libvips/foreign/tiff2vips.c index 6e39a5f7..fe84780b 100644 --- a/libvips/foreign/tiff2vips.c +++ b/libvips/foreign/tiff2vips.c @@ -1904,9 +1904,9 @@ 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[0] == 'I' && str[1] == 'I' && str[2] == '*' && str[3] == '\0')) ) return( TRUE ); return( FALSE ); @@ -1915,10 +1915,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 );