#1 Other components » SynZip: bugfix for zipping a buffer > 200MB » 2013-09-18 20:15:05

jpdk
Replies: 1

Hi Arnaud,

Thank you for an excellent set of components.

I encountered an issue with TZipWrite.AddDeflated for a buffer larger than 200 MB.
I will post the fix here, as I couldn't find a way to open a ticket.

procedure TZipWrite.AddDeflated(const aZipName: TFileName; Buf: pointer;
  Size, CompressLevel, FileAge: integer);
...
      zlastMod := FileAge;
      tmpsize := (Size*11) div 10+12;
      Getmem(tmp,tmpSize);
...

Size*11 will lead to an integer overflow for buffers larger than 200MB.
A simple way to avoid this is:

      tmpsize := (Int64(Size)*11) div 10+12;

Keep up the good work!

J.

Board footer

Powered by FluxBB