Skip to content

Commit 2d2cf3b

Browse files
committed
Merge branch 'PHP-8.1' into PHP-8.2
* PHP-8.1: Fix GH-9397: exif read : warnings and errors : Potentially invalid endianess, Illegal IFD size and Undefined index
2 parents 94a00e9 + b81ce29 commit 2d2cf3b

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

Diff for: NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ PHP NEWS
1414
(Nathan Freeman)
1515
. Fixed incorrect error handling in dom_zvals_to_fragment(). (nielsdos)
1616

17+
- Exif:
18+
. Fixed bug GH-9397 (exif read : warnings and errors : Potentially invalid
19+
endianess, Illegal IFD size and Undefined index). (nielsdos)
20+
1721
- PCRE:
1822
. Fixed bug GH-10968 (Segfault in preg_replace_callback_array()). (ilutov)
1923

Diff for: ext/exif/exif.c

+13-3
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,9 @@ typedef struct {
12771277
mn_offset_mode_t offset_mode;
12781278
} maker_note_type;
12791279

1280+
/* Some maker notes (e.g. DJI info tag) require custom parsing */
1281+
#define REQUIRES_CUSTOM_PARSING NULL
1282+
12801283
/* Remember to update PHP_MINFO if updated */
12811284
static const maker_note_type maker_note_array[] = {
12821285
{ tag_table_VND_CANON, "Canon", NULL, 0, 0, MN_ORDER_INTEL, MN_OFFSET_NORMAL},
@@ -1287,6 +1290,7 @@ static const maker_note_type maker_note_array[] = {
12871290
{ tag_table_VND_OLYMPUS, "OLYMPUS OPTICAL CO.,LTD", "OLYMP\x00\x01\x00", 8, 8, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
12881291
{ tag_table_VND_SAMSUNG, "SAMSUNG", NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
12891292
{ tag_table_VND_PANASONIC, "Panasonic", "Panasonic\x00\x00\x00", 12, 12, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
1293+
{ REQUIRES_CUSTOM_PARSING, "DJI", "[ae_dbg_info:", 13, 13, MN_ORDER_MOTOROLA, MN_OFFSET_NORMAL},
12901294
{ tag_table_VND_DJI, "DJI", NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
12911295
{ tag_table_VND_SONY, "SONY", "SONY DSC \x00\x00\x00", 12, 12, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
12921296
{ tag_table_VND_SONY, "SONY", NULL, 0, 0, MN_ORDER_NORMAL, MN_OFFSET_NORMAL},
@@ -3168,10 +3172,16 @@ static bool exif_process_IFD_in_MAKERNOTE(image_info_type *ImageInfo, char * val
31683172
return true;
31693173
}
31703174

3175+
if (UNEXPECTED(maker_note->tag_table == REQUIRES_CUSTOM_PARSING)) {
3176+
/* Custom parsing required, which is not implemented at this point
3177+
* Return true so that other metadata can still be parsed. */
3178+
return true;
3179+
}
3180+
31713181
dir_start = value_ptr + maker_note->offset;
31723182

31733183
#ifdef EXIF_DEBUG
3174-
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (intptr_t)dir_start-(intptr_t)info->offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (intptr_t)dir_start-(intptr_t)info->offset_base+maker_note->offset+displacement));
3184+
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Process %s @0x%04X + 0x%04X=%d: %s", exif_get_sectionname(section_index), (intptr_t)dir_start-(intptr_t)info->offset_base+maker_note->offset+displacement, value_len, value_len, exif_char_dump(value_ptr, value_len, (intptr_t)dir_start-(intptr_t)info->offset_base+maker_note->offset+displacement));
31753185
#endif
31763186

31773187
ImageInfo->sections_found |= FOUND_MAKERNOTE;
@@ -3330,7 +3340,7 @@ static bool exif_process_IFD_TAG_impl(image_info_type *ImageInfo, char *dir_entr
33303340
#ifdef EXIF_DEBUG
33313341
dump_data = exif_dump_data(&dump_free, format, components, ImageInfo->motorola_intel, value_ptr);
33323342
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE,
3333-
"Process tag(x%04X=%s,@x%04X + x%04X(=%d)): %s%s %s",
3343+
"Process tag(x%04X=%s,@0x%04X + x%04X(=%d)): %s%s %s",
33343344
tag, exif_get_tagname_debug(tag, tag_table), offset_val+displacement, byte_count, byte_count, (components>1)&&format!=TAG_FMT_UNDEFINED&&format!=TAG_FMT_STRING?"ARRAY OF ":"", exif_get_tagformat(format), dump_data);
33353345
if (dump_free) {
33363346
efree(dump_data);
@@ -4173,7 +4183,7 @@ static bool exif_process_IFD_in_TIFF_impl(image_info_type *ImageInfo, size_t dir
41734183
}
41744184
entry_offset = php_ifd_get32u(dir_entry+8, ImageInfo->motorola_intel);
41754185
#ifdef EXIF_DEBUG
4176-
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @x%04X", exif_get_sectionname(sub_section_index), entry_offset);
4186+
exif_error_docref(NULL EXIFERR_CC, ImageInfo, E_NOTICE, "Next IFD: %s @0x%04X", exif_get_sectionname(sub_section_index), entry_offset);
41774187
#endif
41784188
exif_process_IFD_in_TIFF(ImageInfo, entry_offset, sub_section_index);
41794189
if (section_index!=SECTION_THUMBNAIL && entry_tag==TAG_SUB_IFD) {

0 commit comments

Comments
 (0)