mORMot and Open Source friends
Check-in [31b07ab670]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:{2056} let TZipRead handle files with size of 0
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:31b07ab6705726de0ffdf74e41dfc3f007be1f5f
User & Date: ab 2015-11-11 09:25:12
Original Comment: {2056} fixed unexpected GPF in TSQLRibbon.ChangeColorScheme - patch by kevinday
Context
2015-11-11
11:26
{2057} added BorderStyle and BorderWidth optional parameters to TPdfDocument.CreateLink and CreateAnnotation methods check-in: 258e38c50d user: ab tags: trunk
09:25
{2056} let TZipRead handle files with size of 0 check-in: 31b07ab670 user: ab tags: trunk
09:18
{2055} fixed unexpected GPF in TSQLRibbon.ChangeColorScheme - patch by kevinday check-in: 51e9c62af7 user: ab tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to SynZip.pas.

26
27
28
29
30
31
32

33
34
35
36
37
38
39
...
147
148
149
150
151
152
153

154
155
156
157
158
159
160
....
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
....
1279
1280
1281
1282
1283
1284
1285
1286
1287

1288
1289
1290
1291
1292
1293
1294
  The Initial Developer of the Original Code is Arnaud Bouchez.

  Portions created by the Initial Developer are Copyright (C) 2015
  the Initial Developer. All Rights Reserved.

  Contributor(s):
   - Alf

   - jpdk
   - Gigo

  Alternatively, the contents of this file may be used under the terms of
  either the GNU General Public License Version 2 or later (the "GPL"), or
  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  in which case the provisions of the GPL or the LGPL are applicable instead
................................................................................
   - fixed UnZip() when crc and sizes are stored not within the file header,
     but in a separate data descriptor block, after the compressed data (this
     may occur e.g. if the .zip is created with latest Java JRE) - also added
     corresponding TZipRead.RetrieveFileInfo() method and renamed TZipEntry
     info field into infoLocal, and introduced infoDirectory new field
   - renamed ZipFormat parameter to ZlibFormat, and introduce it also for
     uncompression, so that both deflate and zlib layout are handled

   - unit fixed and tested with Delphi XE2 (and up) 64-bit compiler

}

{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64

{$ifdef FPC}
................................................................................
      end;
      inc(PByte(H),sizeof(H^)+infoLocal^.NameLen+H^.fileInfo.extraLen+H^.commentLen);
      if not(infoLocal^.zZipMethod in [Z_STORED,Z_DEFLATED]) then
        raise ESynZipException.CreateFmt(
          'Unsupported compression method %d for %s',[infoLocal^.zZipMethod,zipName]);
      if (zipName='') or (zipName[length(zipName)]='\') then
        continue; // ignore folder
      if infoLocal^.flags and (1 shl 3)=0 then
        if (infoLocal^.zzipSize=0) or (infoLocal^.zfullSize=0) then
          raise ESynZipException.CreateFmt('"%s" size=0 in ZIP',[zipName]);
      inc(Count); // add file to Entry[]
    end;
  end;
end;

constructor TZipRead.Create(Instance: THandle; const ResName: string; ResType: PChar);
// locked resources are memory map of the executable -> direct access is easy
................................................................................
  Info := Entry[Index].infoLocal^;
  if Info.flags and (1 shl 3)=0 then begin
    result := true; // local information is correct
    exit;
  end;
  // get info from ending "central directory" (faster than "data descriptor")
  with Entry[Index].infoDirectory^.fileInfo do
    if (zzipSize<>0) and (zfullSize<>0) and
       (zzipSize<>dword(-1)) and (zfullSize<>dword(-1)) then begin

      Info.zcrc32 := zcrc32;
      Info.zzipSize := zzipSize;
      Info.zfullSize := zfullSize;
      result := true;
      exit;
    end;
  // search manually the "data descriptor" from the binary local data







>







 







>







 







<
<
<







 







<
|
>







26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
....
1180
1181
1182
1183
1184
1185
1186



1187
1188
1189
1190
1191
1192
1193
....
1278
1279
1280
1281
1282
1283
1284

1285
1286
1287
1288
1289
1290
1291
1292
1293
  The Initial Developer of the Original Code is Arnaud Bouchez.

  Portions created by the Initial Developer are Copyright (C) 2015
  the Initial Developer. All Rights Reserved.

  Contributor(s):
   - Alf
   - ehansen
   - jpdk
   - Gigo

  Alternatively, the contents of this file may be used under the terms of
  either the GNU General Public License Version 2 or later (the "GPL"), or
  the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  in which case the provisions of the GPL or the LGPL are applicable instead
................................................................................
   - fixed UnZip() when crc and sizes are stored not within the file header,
     but in a separate data descriptor block, after the compressed data (this
     may occur e.g. if the .zip is created with latest Java JRE) - also added
     corresponding TZipRead.RetrieveFileInfo() method and renamed TZipEntry
     info field into infoLocal, and introduced infoDirectory new field
   - renamed ZipFormat parameter to ZlibFormat, and introduce it also for
     uncompression, so that both deflate and zlib layout are handled
   - allow reading files of size 0 in TZipRead
   - unit fixed and tested with Delphi XE2 (and up) 64-bit compiler

}

{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64

{$ifdef FPC}
................................................................................
      end;
      inc(PByte(H),sizeof(H^)+infoLocal^.NameLen+H^.fileInfo.extraLen+H^.commentLen);
      if not(infoLocal^.zZipMethod in [Z_STORED,Z_DEFLATED]) then
        raise ESynZipException.CreateFmt(
          'Unsupported compression method %d for %s',[infoLocal^.zZipMethod,zipName]);
      if (zipName='') or (zipName[length(zipName)]='\') then
        continue; // ignore folder



      inc(Count); // add file to Entry[]
    end;
  end;
end;

constructor TZipRead.Create(Instance: THandle; const ResName: string; ResType: PChar);
// locked resources are memory map of the executable -> direct access is easy
................................................................................
  Info := Entry[Index].infoLocal^;
  if Info.flags and (1 shl 3)=0 then begin
    result := true; // local information is correct
    exit;
  end;
  // get info from ending "central directory" (faster than "data descriptor")
  with Entry[Index].infoDirectory^.fileInfo do

    if (zzipSize<>dword(-1)) and (zfullSize<>dword(-1)) then begin
      // ZIP64 format not supported yet (sizes=-1)
      Info.zcrc32 := zcrc32;
      Info.zzipSize := zzipSize;
      Info.zfullSize := zfullSize;
      result := true;
      exit;
    end;
  // search manually the "data descriptor" from the binary local data

Changes to SynopseCommit.inc.

1
'1.18.2055'
|
1
'1.18.2056'