-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix Bug #75785: Add extra check for Maker's Note endianness #5849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Different manufacturer models may come with a different endianness (motorola/intel) format. In order to avoid a big refactor and a gigantic lookup table, this commit simply attempts to switch the endianness and proceed when values are acceptable.
Does exif really not have any explicit endianness indication? |
Endianness is defined within the Tiff Header itself.
See https://www.media.mit.edu/pia/Research/deepview/exif.html#TiffHeader. Theoretically the entire file should follow this endianness. Specifically for Maker Note tags (vendor specific) a different endianness can be adopted by vendors. That's why exif.c has this lookup table. What the code doesn't take in consideration is that different camera models may also produce data using a different endianness. In this case we could either create an ever-incomplete lookup table or attempt switching modes. |
@KalleZ Could you please take a look at this? |
Thank you @rmatzinger for providing an image for testing. I've added a test case for this pull request using it. I hope with it the only thing missing will be the code review. |
Thanks for adding the test case. We should try to reduce the size of the file though, as its is 6MB large and only the exif metadata is important. I believe the way to do this is using |
My bad, you're totally right. There it is :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Only thought about this I initially had was the E_NOTICE
, but then again I think it is common practice (sadly) to call exif_read_data()
with the error supression operator anyway, so it's kinda redundant to try hide it.
This pull request adds a naive recovery mechanism for ext/exif when extracting Maker Notes IFD tags and solves most of the warnings described in this bug ticket
The current behaviour expects the byte order to follow the same defined in the TIFF header. But some manufacturers might change this order. That's why the current exif.c file has a lookup table with valid manufacturers and their expected endianness.
Different camera models may also produce IFD Tags using a byte order other than the one specified by the lookup table. For this case, this pull request adds a naive attempt to switch the byte order before completely failing.
Original context where this pull request came from: nawarian/The-PHP-Website#32