gomfunkel / node-exif

A node.js library to extract Exif metadata from images.
MIT License
581 stars 104 forks source link

Handle invalid IFD #14

Open lhagan opened 11 years ago

lhagan commented 11 years ago

I ran node-exif over about 6000 photos, and it got hung up on just one. In this case, it looks like the IFD was invalid, so whereas there would normally be a few IFD entires to loop over, node-exif detected over 10000. Not exactly an infinite loop, but it effectively approximates one. This is definitely a problem with the image; exiftool fails gracefully and reports: "Bad ExifIFD directory" when reading the same file.

I was able to quickly fix this by adding a sanity check: if the number of entries exceeds 1000, something's got to be wrong so I had it bail out. There's probably a better way to solve this problem, but I figured submitting a pull request would at least be a good way to bring attention to this edge case.

gomfunkel commented 10 years ago

Shame on me for taking this long for a reply but if I'm not totally mistaken the latest version 0.3.6 available from npm should fix this issue.

Please check your image again with this version. If it still doesn't work please attach the image causing the error to this issue so I can find a solution to the problem.

lhagan commented 10 years ago

Sorry for taking so long to get back to you on this. I had misplaced the image in question, but finally tracked it down today. The problem still exists as of 0.4.0. img_0026

lacombar commented 9 years ago

The patch is incorrect, AFAIK, there is nothing wrong with a >1000 entry IFD...