Skip to content

Commit

Permalink
ExifImage: try to handle incorrect IFD format more gracefully
Browse files Browse the repository at this point in the history
Test image provided in gomfunkel#14.
  • Loading branch information
Arnaud Lacombe authored and lacombar committed Feb 23, 2015
1 parent 2c143c6 commit e72587a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/exif/ExifImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ ExifImage.prototype.extractExifIFDEntries = function (data, offset, store, tags)
{
var entryCount = data.readUInt16(offset)

if (entryCount * 12 > data.length)
throw new Error("Invalid number of IFD entries")

for (var i = 0; i < entryCount; i++) {
var start = offset + 2 + (i * 12)
var entry = this.extractExifEntry(data, start, tags)
Expand Down Expand Up @@ -385,6 +388,9 @@ ExifImage.prototype.extractExifEntry = function (data, entryOffset, tags)
}

type = ExifImage.TIFFTYPES[field.type]
if (type == undefined)
return false

type.size = type.len * type.count

offset = entryOffset + 8
Expand Down

0 comments on commit e72587a

Please sign in to comment.