From a18a3058063bc62f98b87b99a1f0a77d153f1e74 Mon Sep 17 00:00:00 2001 From: wp_xxyyzz Date: Fri, 11 Oct 2024 22:50:12 +0000 Subject: [PATCH] fpexif: Fix exif reader stopping when a tag with illegal tag type (e.g. 0) is found (https://forum.lazarus.freepascal.org/index.php/topic,68879.msg533245.html) git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@9484 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- components/fpexif/fpeexifreadwrite.pas | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/components/fpexif/fpeexifreadwrite.pas b/components/fpexif/fpeexifreadwrite.pas index 44b7439c6..11f350eae 100644 --- a/components/fpexif/fpeexifreadwrite.pas +++ b/components/fpexif/fpeexifreadwrite.pas @@ -352,16 +352,21 @@ begin Continue; end; + // Unexpected end of directory (4 zero bytes), so breaking here. + // see: https://bugs.freepascal.org/view.php?id=38904 if (ifdRec.TagID = 0) and (ifdRec.DataType = 0) then - // Unexpected end of directory (4 zero bytes), so breaking here. - // see: https://bugs.freepascal.org/view.php?id=38904 Break; ifdRec.TagID := FixEndian16(ifdRec.TagID); ifdRec.DataType := FixEndian16(ifdRec.DataType); - if not (ifdRec.DataType in [1..ord(High(TTagType))]) then begin + + // Illegal data type: https://forum.lazarus.freepascal.org/index.php/topic,68879.msg533245.html + // --> we skip this tag + if not (ifdRec.DataType in [1..ord(High(TTagType))]) then + begin Warning(Format(rsIncorrectTagType, [ifdRec.DataType, i, ifdRec.TagID, FImgInfo.Filename])); - break; + tagPos := tagPos + SizeOf(TIFDRecord); + Continue; end; ifdRec.DataCount := FixEndian32(ifdRec.DataCount);