ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 The program enters an infinite loop when reading Exif
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

Sviat

Russia
1 Posts

Posted - Sep 26 2024 :  09:37:18  Show Profile  Reply
Delphi 12.2
Target platform: Win64
Configuration: Release

With optimization enabled (Release configuration), the program enters an infinite loop when reading Exif data from an attached image.
This happens because the number of bytes read is not checked in the IEStreamReadWord, IEStreamReadDWord, IEStreamReadInt64 functions.

The correct solution: check the result of Stream.Read
Simple solution: Resilt:=0 before Stream.Read


procedure TestBug_Full;
begin
  var ImageEnIO := TImageEnIO.Create(nil);
  try
    IEGlobalSettings().JPEGEngine := iecrLibRaw;
    ImageEnIO.ParamsFromFile('BUG.jpeg', ioJPEG);
  finally
    ImageEnIO.Free;
  end;
end;

procedure TestBug_Short;
const ExifData: TBytes = [
  69,120,105,102,0,0,77,77,0,42,0,0,0,8,0,4,1,15,0,2,0,0,0,6,0,0,0,62,1,16,0,2,0,0,0,13,0,0,0,
  68,130,154,0,5,0,0,0,1,0,0,0,81,135,105,0,4,0,0,0,1,0,0,0,89,0,0,0,0,67,97,110,111,110,0,67,97,
  110,111,110,32,69,79,83,32,54,68,0,0,0,0,30,0,0,0,1,0,6,130,154,0,5,0,0,0,1,0,0,0,163,130,157,0,
  5,0,0,0,1,0,0,0,171,136,39,0,3,0,0,0,2,0,100,0,0,144,3,0,2,0,0,0,20,0,0,0,179,146,9,0,3,0,0,
  0,2,0,16,0,0,146,10,0,5,0,0,0,1,0,0,0,199,0,0,0,30,0,0,0,1,0,0,0,22,0,0,0,1,50,48,49,52,58,
  48,52,58,49,56,32,48,51,58,52,48,58,51,57,0,0,0,0,17,0,0,0,1
];
begin
  var Params := TIOParams.Create;
  try
    LoadEXIFFromStandardBuffer(Pointer(ExifData), Length(ExifData), Params, True);
  finally
    Params.Free;
  end;
end;


attach/Sviat/20249269371_BUG.zip
40.02 KB

xequte

38531 Posts

Posted - Sep 26 2024 :  19:15:04  Show Profile  Reply
Thank you, we'll have a fix for this in our upcoming release.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: