Skip to content

Commit 30fe4e4

Browse files
committed
Don't misinterpret DJI info maker note as DJI maker note
The DJI and DJI info maker note both share the "DJI" make string. This caused the current code to try to interpret the DJI info maker note as a DJI maker note. However, the DJI info maker note requires custom parsing. Therefore, the misinterpretation actually caused the current code to believe that there was an unrecoverable error in the IFD for the maker note by returning false in the maker note parser. This in turn caused the inability to parse other EXIF metadata. This patch adds the identification of the DJI info maker note so that it cannot be misinterpreted. Since we don't implement custom parsing, it achieves this by setting the tag list to a special marker value (in this case the NULL pointer). When this marker value is detected, the function will just skip parsing the maker note and return true. Therefore, the other code will believe that the IFD is not corrupt. This approach is similar to handing an unrecognised maker note type (see the loop on top of exif_process_IFD_in_MAKERNOTE() which also returns true and treats it as a string). The end result of this patch is that the DJI info maker note is considered as unknown to the caller of exif_process_IFD_in_MAKERNOTE(), and therefore that the other EXIF metadata can be parsed successfully.
1 parent 14f2541 commit 30fe4e4

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ext/exif/exif.c

Lines changed: 10 additions & 0 deletions
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,6 +3172,12 @@ 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

0 commit comments

Comments
 (0)