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;
|
i: Integer;
|
||||||
ifdRec: TIFDRecord;
|
ifdRec: TIFDRecord;
|
||||||
byteCount: Integer;
|
byteCount: Integer;
|
||||||
data: TBytes;
|
data: TBytes = nil;
|
||||||
n: Int64;
|
n: Int64;
|
||||||
tagPos: Int64;
|
tagPos: Int64;
|
||||||
newPos: Int64;
|
newPos: Int64;
|
||||||
begin
|
begin
|
||||||
|
ifdRec := Default(TIFDRecord);
|
||||||
|
|
||||||
// Read count of directory entries
|
// Read count of directory entries
|
||||||
numRecords := FixEndian16(ReadWord(AStream));
|
numRecords := FixEndian16(ReadWord(AStream));
|
||||||
if (AParent = TAGPARENT_THUMBNAIL) and (numRecords > 10) then begin
|
if (AParent = TAGPARENT_THUMBNAIL) and (numRecords > 10) then begin
|
||||||
@@ -326,7 +328,7 @@ begin
|
|||||||
AStream.Position := tagPos;
|
AStream.Position := tagPos;
|
||||||
// Read directory entry...
|
// Read directory entry...
|
||||||
n := SizeOf(ifdRec);
|
n := SizeOf(ifdRec);
|
||||||
if AStream.Read(ifdRec{%H-}, n) < n then begin
|
if AStream.Read(ifdRec, n) < n then begin
|
||||||
Error(Format(rsReadIncompleteIFDRecord, [tagPos]));
|
Error(Format(rsReadIncompleteIFDRecord, [tagPos]));
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@@ -334,10 +336,17 @@ begin
|
|||||||
if (ifdRec.TagID = 0) and (ifdRec.DataType = 0) and (ifdRec.DataCount = 0) and (ifdRec.DataValue = 0) then
|
if (ifdRec.TagID = 0) and (ifdRec.DataType = 0) and (ifdRec.DataCount = 0) and (ifdRec.DataValue = 0) then
|
||||||
begin
|
begin
|
||||||
// This is an empty IFD entry as found in images of the YUNEEC CGO3 camera
|
// 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;
|
Continue;
|
||||||
end;
|
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.TagID := FixEndian16(ifdRec.TagID);
|
||||||
ifdRec.DataType := FixEndian16(ifdRec.DataType);
|
ifdRec.DataType := FixEndian16(ifdRec.DataType);
|
||||||
if not (ifdRec.DataType in [1..ord(High(TTagType))]) then begin
|
if not (ifdRec.DataType in [1..ord(High(TTagType))]) then begin
|
||||||
|
Reference in New Issue
Block a user