Verify ISO/3GPP2 signature in heifload is_a check

This commit is contained in:
Lovell Fuller 2020-09-22 21:19:53 +01:00
parent 58a327b7f9
commit 1922a97a85
1 changed files with 6 additions and 0 deletions

View File

@ -260,9 +260,15 @@ static const char *heif_magic[] = {
static int static int
vips_foreign_load_heif_is_a( const char *buf, int len ) vips_foreign_load_heif_is_a( const char *buf, int len )
{ {
static unsigned char iso[4] = { 0, 0, 0, 24 };
static unsigned char three_gp[4] = { 0, 0, 0, 32 };
if( len >= 12 ) { if( len >= 12 ) {
int i; int i;
if ( memcmp( buf, iso, 4 ) != 0 && memcmp( buf, three_gp, 4 ) != 0 )
return ( 0 );
for( i = 0; i < VIPS_NUMBER( heif_magic ); i++ ) for( i = 0; i < VIPS_NUMBER( heif_magic ); i++ )
if( strncmp( buf + 4, heif_magic[i], 8 ) == 0 ) if( strncmp( buf + 4, heif_magic[i], 8 ) == 0 )
return( 1 ); return( 1 );