#1 2019-05-09 09:37:27

MC
Member
Registered: 2012-10-04
Posts: 21

SynZip.pas missing SynCommons use clause ?

Hello,

I am using TZipRead under Delphi 7 Pro and open a .zip archive file directly from memory with the constructor

constructor Create(BufZip: PByteArray; Size: cardinal);

.

I was surprised that PByteArray was a reference to SysUtils and not SynCommons ("array[0..32767] of Byte" vs "array[0..MaxInt-1] of Byte").

Is there a reason for this?

Thank you

Offline

#2 2019-05-09 13:23:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,205
Website

Re: SynZip.pas missing SynCommons use clause ?

It is on purpose: SynCommons.pas is NOT used at all in SynZip.pas.

So that you could use SynZip with no dependency - e.g. for a small "Setup" program, or as a faster and cross-platform replacement to the ZLib unit.

Offline

#3 2019-05-09 13:35:20

MC
Member
Registered: 2012-10-04
Posts: 21

Re: SynZip.pas missing SynCommons use clause ?

Thank you ab for your response.

I tried to open .zip archives from memory with size > 32768 bytes and it did not failed. Unzip was correct.

however, is this secure?

Offline

#4 2019-05-09 14:58:56

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,205
Website

Re: SynZip.pas missing SynCommons use clause ?

Why wouldn't it be secure?

Offline

#5 2019-05-09 15:18:48

MC
Member
Registered: 2012-10-04
Posts: 21

Re: SynZip.pas missing SynCommons use clause ?

Sorry, I meant sure...

Because if PByteArray is an array of 32768 bytes (as declared in SysUtils), I am not supposed to use more than 32768 bytes, no ?

For example, this code worked with a zip of 27,4 Mo :

var
  vContent : RawByteString;
  vZip :TZipRead;
begin
  vContent := StringFromFile('TeamViewerPortable-14.zip');
  vZip := TZipRead.Create(@vContent[1], Length(vContent));
  vZip.UnZipAll('c:\temp\');
  vZip.Free;
end;

I thought Delphi would give me an error.
There is a subtlety that I do not understand ...

Offline

#6 2019-05-09 18:51:48

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,205
Website

Re: SynZip.pas missing SynCommons use clause ?

Only if "Range Error" checking is set, which is not the case for all of our units - there is a {$I Synopse.inc} at the top of each source which set {$R-} for the whole unit.

Offline

Board footer

Powered by FluxBB