Skip to content

ext/exif: spell the Exif identifier code as a char literal#22241

Merged
Girgias merged 1 commit into
php:masterfrom
iliaal:exif-cleanup
Jun 14, 2026
Merged

ext/exif: spell the Exif identifier code as a char literal#22241
Girgias merged 1 commit into
php:masterfrom
iliaal:exif-cleanup

Conversation

@iliaal

@iliaal iliaal commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the review on #22213: replace the {0x45, 0x78, 0x69, 0x66, 0x00, 0x00} byte arrays for the Exif identifier with the equivalent {'E', 'x', 'i', 'f', 0, 0} in both the APP1 and WebP checks. Byte-identical, just more readable.

P.S. I looked at the other suggestion (endian) rename but the delta was way too big, so decided to leave it be for now.

The {0x45, 0x78, 0x69, 0x66, 0x00, 0x00} arrays are the ASCII bytes for
"Exif\0\0"; the char form is byte-identical and self-documenting.
@iliaal iliaal requested a review from Girgias June 6, 2026 14:45
@LamentXU123

Copy link
Copy Markdown
Contributor

LGTM but may still need to wait for Gina's opinion :)

Comment thread ext/exif/exif.c
{
/* Check the APP1 for Exif Identifier Code */
static const uchar ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
static const uchar ExifHeader[] = {'E', 'x', 'i', 'f', 0, 0};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't this just be "Exif\x00\x00" directly in the memcmp()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for this one, but the HEIF check in exif_scan_HEIF_header() uses sizeof(ExifHeader) for both the compare length and the skip offset, so it needs the named array there. Kept this site matching it rather than splitting the style across the two.

@iliaal iliaal requested a review from TimWolla June 13, 2026 12:27

@Girgias Girgias left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks :)

@Girgias Girgias merged commit b6385ef into php:master Jun 14, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants