Merge pull request #1828 from lovell/heif-verify-iso-container

heifload: verify ISO BMFF/3GPP2 signature in is_a check
This commit is contained in:
John Cupitt 2020-09-23 07:50:12 +01:00 committed by GitHub
commit 73ef7dbf2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -260,9 +260,15 @@ static const char *heif_magic[] = {
static int
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 ) {
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++ )
if( strncmp( buf + 4, heif_magic[i], 8 ) == 0 )
return( 1 );