You've already forked lazarus-ccr
fpexif: Fix exif reader when pre-mature end-of-directory value is found in IFD. Issue #38904, patch by regs.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8044 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -309,11 +309,13 @@ var
|
||||
i: Integer;
|
||||
ifdRec: TIFDRecord;
|
||||
byteCount: Integer;
|
||||
data: TBytes;
|
||||
data: TBytes = nil;
|
||||
n: Int64;
|
||||
tagPos: Int64;
|
||||
newPos: Int64;
|
||||
begin
|
||||
ifdRec := Default(TIFDRecord);
|
||||
|
||||
// Read count of directory entries
|
||||
numRecords := FixEndian16(ReadWord(AStream));
|
||||
if (AParent = TAGPARENT_THUMBNAIL) and (numRecords > 10) then begin
|
||||
@ -326,7 +328,7 @@ begin
|
||||
AStream.Position := tagPos;
|
||||
// Read directory entry...
|
||||
n := SizeOf(ifdRec);
|
||||
if AStream.Read(ifdRec{%H-}, n) < n then begin
|
||||
if AStream.Read(ifdRec, n) < n then begin
|
||||
Error(Format(rsReadIncompleteIFDRecord, [tagPos]));
|
||||
exit;
|
||||
end;
|
||||
@ -334,10 +336,17 @@ begin
|
||||
if (ifdRec.TagID = 0) and (ifdRec.DataType = 0) and (ifdRec.DataCount = 0) and (ifdRec.DataValue = 0) then
|
||||
begin
|
||||
// This is an empty IFD entry as found in images of the YUNEEC CGO3 camera
|
||||
AStream.Position := AStream.Position + n;
|
||||
// see: https://www.lazarusforum.de/viewtopic.php?f=18&t=13356 and
|
||||
// https://bugs.freepascal.org/view.php?id=38904
|
||||
tagPos := tagPos + n;
|
||||
Continue;
|
||||
end;
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user