devongovett / exif-reader

A small EXIF image metadata reader
MIT License
145 stars 22 forks source link

Exit early in case of unknown or bogus tag type #9

Closed inukshuk closed 4 years ago

inukshuk commented 7 years ago

When parsing corrupted files, I frequently ran into un-catchable errors for invalid tag types. Basically, if the type is invalid, this will cause undefined / NaN values for valueSize and valueOffset; because the type is not known readValue in the loop at the end of readTag will not actually do anything, but keep pushing undefined into the res array numValue times. Given bad input numValue can be extremely large so that the loop crashes Node.

lovell commented 4 years ago

@inukshuk Thank you Sylvester!