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
This commit is contained in:
wp_xxyyzz 2024-10-11 22:50:12 +00:00
parent 6f5ac5dcf0
commit a18a305806

View File

@ -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);