@@ -1606,6 +1606,8 @@ static void exif_process_IFD_in_JPEG(image_info_type *ImageInfo, char *DirStart,
1606
1606
*/
1607
1607
static void exif_process_TIFF_in_JPEG (image_info_type * ImageInfo , char * CharBuf , unsigned int length )
1608
1608
{
1609
+ unsigned exif_value_2a , offset_of_ifd ;
1610
+
1609
1611
/* set the thumbnail stuff to nothing so we can test to see if they get set up */
1610
1612
if (memcmp (CharBuf , "II" , 2 ) == 0 ) {
1611
1613
ImageInfo -> motorola_intel = 0 ;
@@ -1617,14 +1619,15 @@ static void exif_process_TIFF_in_JPEG(image_info_type *ImageInfo, char *CharBuf,
1617
1619
}
1618
1620
1619
1621
/* Check the next two values for correctness. */
1620
- if (php_ifd_get16u (CharBuf + 2 , ImageInfo -> motorola_intel ) != 0x2a
1621
- || php_ifd_get32u (CharBuf + 4 , ImageInfo -> motorola_intel ) != 0x08 ) {
1622
+ exif_value_2a = php_ifd_get16u (CharBuf + 2 , ImageInfo -> motorola_intel );
1623
+ offset_of_ifd = php_ifd_get32u (CharBuf + 4 , ImageInfo -> motorola_intel );
1624
+ if ( exif_value_2a != 0x2a || offset_of_ifd < 0x08 ) {
1622
1625
php_error (E_WARNING , "Invalid TIFF start (1)" );
1623
1626
return ;
1624
1627
}
1625
1628
1626
1629
/* First directory starts at offset 8. Offsets starts at 0. */
1627
- exif_process_IFD_in_JPEG (ImageInfo , CharBuf + 8 , CharBuf , length /*-14*/ , SECTION_IFD0 );
1630
+ exif_process_IFD_in_JPEG (ImageInfo , CharBuf + offset_of_ifd , CharBuf , length /*-14*/ , SECTION_IFD0 );
1628
1631
1629
1632
#ifdef EXIF_DEBUG
1630
1633
php_error (E_NOTICE ,"exif_process_TIFF_in_JPEG, done" );
0 commit comments