rwcarlsen / goexif

Decode embedded EXIF meta data from image files.
BSD 2-Clause "Simplified" License
627 stars 134 forks source link

tiff: ignore all trailing NULLs in case of misleading Count #58

Closed mpl closed 6 years ago

mpl commented 6 years ago

As it can apparently happen with some camera software (https://user-images.githubusercontent.com/2621/39392188-71a66fc4-4a66-11e8-9e3b-694163efa643.jpg), sometimes a tag bytes will not only have a bunch of trailing NULLs, but the Count for the data in that tag will be wrongly set too. i.e. instead of being set to the actual number of relevant bytes to read, it will be set to the full number of bytes, trailing zeroes included.

As a consequence, the Tag.strVal returned would include these trailing NULLs too, which would lead to bugs such as https://github.com/perkeep/perkeep/issues/1127

This change therefore makes sure to remove all trailing NULLs from the data, in the case of DTAscii at least.

mpl commented 6 years ago

@bradfitz PTAL