From 33ee3a8313dabf9054611087d8314d9b4057c883 Mon Sep 17 00:00:00 2001 From: Dustin Oprea Date: Tue, 21 Jul 2020 23:35:36 -0400 Subject: [PATCH] ifd_enumerate.go: Do not allow unnecessary thumbnail read to disrupt enumeration --- v3/ifd_enumerate.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/v3/ifd_enumerate.go b/v3/ifd_enumerate.go index 0aeb530..6fde9af 100644 --- a/v3/ifd_enumerate.go +++ b/v3/ifd_enumerate.go @@ -486,20 +486,24 @@ func (ie *IfdEnumerate) parseIfd(ii *exifcommon.IfdIdentity, bp *byteParser, vis if enumeratorThumbnailOffset != nil && enumeratorThumbnailSize != nil { thumbnailData, err = ie.parseThumbnail(enumeratorThumbnailOffset, enumeratorThumbnailSize) - log.PanicIf(err) + if err != nil { + ifdEnumerateLogger.Errorf( + nil, err, + "We tried to bump our furthest-offset counter but there was an issue first seeking past the thumbnail.") + } else { + // In this case, the value is always an offset. + offset := enumeratorThumbnailOffset.getValueOffset() - // In this case, the value is always an offset. - offset := enumeratorThumbnailOffset.getValueOffset() + // This this case, the value is always a length. + length := enumeratorThumbnailSize.getValueOffset() - // This this case, the value is always a length. - length := enumeratorThumbnailSize.getValueOffset() + ifdEnumerateLogger.Debugf(nil, "Found thumbnail in IFD [%s]. Its offset is (%d) and is (%d) bytes.", ii, offset, length) - ifdEnumerateLogger.Debugf(nil, "Found thumbnail in IFD [%s]. Its offset is (%d) and is (%d) bytes.", ii, offset, length) + furthestOffset := offset + length - furthestOffset := offset + length - - if furthestOffset > ie.furthestOffset { - ie.furthestOffset = furthestOffset + if furthestOffset > ie.furthestOffset { + ie.furthestOffset = furthestOffset + } } }