Merge pull request #187 from lovell/tiff-tightener-7.40

Verify first 4 bytes of TIFF file
This commit is contained in:
John Cupitt 2014-10-27 12:55:11 +00:00
commit 675bc71294

View File

@ -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 );