Mercurial > hg > orthanc
annotate OrthancFramework/Resources/ThirdParty/minizip/unzip.c @ 5582:17da828f9443 find-refactoring
removed FindResponse::Item::level_
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Sat, 27 Apr 2024 21:42:32 +0200 |
parents | 8174e45f48d8 |
children |
rev | line source |
---|---|
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1 /* unzip.c -- IO for uncompress .zip files using zlib |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
2 Version 1.1, February 14h, 2010 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
3 part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
4 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
5 Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
6 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
7 Modifications of Unzip for Zip64 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
8 Copyright (C) 2007-2008 Even Rouault |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
9 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
10 Modifications for Zip64 support on both zip and unzip |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
11 Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
12 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
13 For more info read MiniZip_info.txt |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
14 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
15 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
16 ------------------------------------------------------------------------------------ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
17 Decryption code comes from crypt.c by Info-ZIP but has been greatly reduced in terms of |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
18 compatibility with older software. The following is from the original crypt.c. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
19 Code woven in by Terry Thorsen 1/2003. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
20 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
21 Copyright (c) 1990-2000 Info-ZIP. All rights reserved. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
22 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
23 See the accompanying file LICENSE, version 2000-Apr-09 or later |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
24 (the contents of which are also included in zip.h) for terms of use. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
25 If, for some reason, all these files are missing, the Info-ZIP license |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
26 also may be found at: ftp://ftp.info-zip.org/pub/infozip/license.html |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
27 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
28 crypt.c (full version) by Info-ZIP. Last revised: [see crypt.h] |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
29 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
30 The encryption/decryption parts of this source code (as opposed to the |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
31 non-echoing password parts) were originally written in Europe. The |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
32 whole source package can be freely distributed, including from the USA. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
33 (Prior to January 2000, re-export from the US was a violation of US law.) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
34 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
35 This encryption code is a direct transcription of the algorithm from |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
36 Roger Schlafly, described by Phil Katz in the file appnote.txt. This |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
37 file (appnote.txt) is distributed with the PKZIP program (even in the |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
38 version without encryption capabilities). |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
39 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
40 ------------------------------------------------------------------------------------ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
41 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
42 Changes in unzip.c |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
43 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
44 2007-2008 - Even Rouault - Addition of cpl_unzGetCurrentFileZStreamPos |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
45 2007-2008 - Even Rouault - Decoration of symbol names unz* -> cpl_unz* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
46 2007-2008 - Even Rouault - Remove old C style function prototypes |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
47 2007-2008 - Even Rouault - Add unzip support for ZIP64 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
48 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
49 Copyright (C) 2007-2008 Even Rouault |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
50 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
51 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
52 Oct-2009 - Mathias Svensson - Removed cpl_* from symbol names (Even Rouault added them but since this is now moved to a new project (minizip64) I renamed them again). |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
53 Oct-2009 - Mathias Svensson - Fixed problem if uncompressed size was > 4G and compressed size was <4G |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
54 should only read the compressed/uncompressed size from the Zip64 format if |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
55 the size from normal header was 0xFFFFFFFF |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
56 Oct-2009 - Mathias Svensson - Applied some bug fixes from patches received from Gilles Vollant |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
57 Oct-2009 - Mathias Svensson - Applied support to unzip files with compression method BZIP2 (bzip2 lib is required) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
58 Patch created by Daniel Borca |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
59 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
60 Jan-2010 - back to unzip and minizip 1.0 name scheme, with compatibility layer |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
61 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
62 Copyright (C) 1998 - 2010 Gilles Vollant, Even Rouault, Mathias Svensson |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
63 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
64 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
65 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
66 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
67 #include <stdio.h> |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
68 #include <stdlib.h> |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
69 #include <string.h> |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
70 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
71 #ifndef NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
72 #define NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
73 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
74 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
75 #include "zlib.h" |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
76 #include "unzip.h" |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
77 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
78 #ifdef STDC |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
79 # include <stddef.h> |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
80 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
81 #ifdef NO_ERRNO_H |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
82 extern int errno; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
83 #else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
84 # include <errno.h> |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
85 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
86 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
87 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
88 #ifndef local |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
89 # define local static |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
90 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
91 /* compile with -Dlocal if your debugger can't find static symbols */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
92 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
93 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
94 #ifndef CASESENSITIVITYDEFAULT_NO |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
95 # if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
96 # define CASESENSITIVITYDEFAULT_NO |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
97 # endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
98 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
99 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
100 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
101 #ifndef UNZ_BUFSIZE |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
102 #define UNZ_BUFSIZE (16384) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
103 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
104 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
105 #ifndef UNZ_MAXFILENAMEINZIP |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
106 #define UNZ_MAXFILENAMEINZIP (256) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
107 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
108 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
109 #ifndef ALLOC |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
110 # define ALLOC(size) (malloc(size)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
111 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
112 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
113 #define SIZECENTRALDIRITEM (0x2e) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
114 #define SIZEZIPLOCALHEADER (0x1e) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
115 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
116 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
117 const char unz_copyright[] = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
118 " unzip 1.01 Copyright 1998-2004 Gilles Vollant - http://www.winimage.com/zLibDll"; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
119 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
120 /* unz_file_info_interntal contain internal info about a file in zipfile*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
121 typedef struct unz_file_info64_internal_s |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
122 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
123 ZPOS64_T offset_curfile;/* relative offset of local header 8 bytes */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
124 } unz_file_info64_internal; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
125 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
126 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
127 /* file_in_zip_read_info_s contain internal information about a file in zipfile, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
128 when reading and decompress it */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
129 typedef struct |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
130 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
131 char *read_buffer; /* internal buffer for compressed data */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
132 z_stream stream; /* zLib stream structure for inflate */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
133 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
134 #ifdef HAVE_BZIP2 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
135 bz_stream bstream; /* bzLib stream structure for bziped */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
136 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
137 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
138 ZPOS64_T pos_in_zipfile; /* position in byte on the zipfile, for fseek*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
139 uLong stream_initialised; /* flag set if stream structure is initialised*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
140 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
141 ZPOS64_T offset_local_extrafield;/* offset of the local extra field */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
142 uInt size_local_extrafield;/* size of the local extra field */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
143 ZPOS64_T pos_local_extrafield; /* position in the local extra field in read*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
144 ZPOS64_T total_out_64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
145 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
146 uLong crc32; /* crc32 of all data uncompressed */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
147 uLong crc32_wait; /* crc32 we must obtain after decompress all */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
148 ZPOS64_T rest_read_compressed; /* number of byte to be decompressed */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
149 ZPOS64_T rest_read_uncompressed;/*number of byte to be obtained after decomp*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
150 zlib_filefunc64_32_def z_filefunc; |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
151 voidpf filestream; /* io structure of the zipfile */ |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
152 uLong compression_method; /* compression method (0==store) */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
153 ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
154 int raw; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
155 } file_in_zip64_read_info_s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
156 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
157 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
158 /* unz64_s contain internal information about the zipfile |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
159 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
160 typedef struct |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
161 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
162 zlib_filefunc64_32_def z_filefunc; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
163 int is64bitOpenFunction; |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
164 voidpf filestream; /* io structure of the zipfile */ |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
165 unz_global_info64 gi; /* public global information */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
166 ZPOS64_T byte_before_the_zipfile;/* byte before the zipfile, (>0 for sfx)*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
167 ZPOS64_T num_file; /* number of the current file in the zipfile*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
168 ZPOS64_T pos_in_central_dir; /* pos of the current file in the central dir*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
169 ZPOS64_T current_file_ok; /* flag about the usability of the current file*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
170 ZPOS64_T central_pos; /* position of the beginning of the central dir*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
171 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
172 ZPOS64_T size_central_dir; /* size of the central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
173 ZPOS64_T offset_central_dir; /* offset of start of central directory with |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
174 respect to the starting disk number */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
175 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
176 unz_file_info64 cur_file_info; /* public info about the current file in zip*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
177 unz_file_info64_internal cur_file_info_internal; /* private info about it*/ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
178 file_in_zip64_read_info_s* pfile_in_zip_read; /* structure about the current |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
179 file if we are decompressing it */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
180 int encrypted; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
181 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
182 int isZip64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
183 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
184 # ifndef NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
185 unsigned long keys[3]; /* keys defining the pseudo-random sequence */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
186 const z_crc_t* pcrc_32_tab; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
187 # endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
188 } unz64_s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
189 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
190 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
191 #ifndef NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
192 #include "crypt.h" |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
193 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
194 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
195 |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
196 /* =========================================================================== |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
197 Reads a long in LSB order from the given gz_stream. Sets |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
198 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
199 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
200 local int unz64local_getShort(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
201 voidpf filestream, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
202 uLong *pX) { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
203 unsigned char c[2]; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
204 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,2); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
205 if (err==2) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
206 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
207 *pX = c[0] | ((uLong)c[1] << 8); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
208 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
209 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
210 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
211 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
212 *pX = 0; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
213 if (ZERROR64(*pzlib_filefunc_def,filestream)) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
214 return UNZ_ERRNO; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
215 else |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
216 return UNZ_EOF; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
217 } |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
218 } |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
219 |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
220 local int unz64local_getLong(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
221 voidpf filestream, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
222 uLong *pX) { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
223 unsigned char c[4]; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
224 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,4); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
225 if (err==4) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
226 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
227 *pX = c[0] | ((uLong)c[1] << 8) | ((uLong)c[2] << 16) | ((uLong)c[3] << 24); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
228 return UNZ_OK; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
229 } |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
230 else |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
231 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
232 *pX = 0; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
233 if (ZERROR64(*pzlib_filefunc_def,filestream)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
234 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
235 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
236 return UNZ_EOF; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
237 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
238 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
239 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
240 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
241 local int unz64local_getLong64(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
242 voidpf filestream, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
243 ZPOS64_T *pX) { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
244 unsigned char c[8]; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
245 int err = (int)ZREAD64(*pzlib_filefunc_def,filestream,c,8); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
246 if (err==8) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
247 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
248 *pX = c[0] | ((ZPOS64_T)c[1] << 8) | ((ZPOS64_T)c[2] << 16) | ((ZPOS64_T)c[3] << 24) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
249 | ((ZPOS64_T)c[4] << 32) | ((ZPOS64_T)c[5] << 40) | ((ZPOS64_T)c[6] << 48) | ((ZPOS64_T)c[7] << 56); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
250 return UNZ_OK; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
251 } |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
252 else |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
253 { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
254 *pX = 0; |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
255 if (ZERROR64(*pzlib_filefunc_def,filestream)) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
256 return UNZ_ERRNO; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
257 else |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
258 return UNZ_EOF; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
259 } |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
260 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
261 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
262 /* My own strcmpi / strcasecmp */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
263 local int strcmpcasenosensitive_internal(const char* fileName1, const char* fileName2) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
264 for (;;) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
265 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
266 char c1=*(fileName1++); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
267 char c2=*(fileName2++); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
268 if ((c1>='a') && (c1<='z')) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
269 c1 -= 0x20; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
270 if ((c2>='a') && (c2<='z')) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
271 c2 -= 0x20; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
272 if (c1=='\0') |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
273 return ((c2=='\0') ? 0 : -1); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
274 if (c2=='\0') |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
275 return 1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
276 if (c1<c2) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
277 return -1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
278 if (c1>c2) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
279 return 1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
280 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
281 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
282 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
283 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
284 #ifdef CASESENSITIVITYDEFAULT_NO |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
285 #define CASESENSITIVITYDEFAULTVALUE 2 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
286 #else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
287 #define CASESENSITIVITYDEFAULTVALUE 1 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
288 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
289 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
290 #ifndef STRCMPCASENOSENTIVEFUNCTION |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
291 #define STRCMPCASENOSENTIVEFUNCTION strcmpcasenosensitive_internal |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
292 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
293 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
294 /* |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
295 Compare two filenames (fileName1,fileName2). |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
296 If iCaseSensitivity = 1, comparison is case sensitive (like strcmp) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
297 If iCaseSensitivity = 2, comparison is not case sensitive (like strcmpi |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
298 or strcasecmp) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
299 If iCaseSensitivity = 0, case sensitivity is default of your operating system |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
300 (like 1 on Unix, 2 on Windows) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
301 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
302 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
303 extern int ZEXPORT unzStringFileNameCompare (const char* fileName1, |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
304 const char* fileName2, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
305 int iCaseSensitivity) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
306 if (iCaseSensitivity==0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
307 iCaseSensitivity=CASESENSITIVITYDEFAULTVALUE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
308 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
309 if (iCaseSensitivity==1) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
310 return strcmp(fileName1,fileName2); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
311 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
312 return STRCMPCASENOSENTIVEFUNCTION(fileName1,fileName2); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
313 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
314 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
315 #ifndef BUFREADCOMMENT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
316 #define BUFREADCOMMENT (0x400) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
317 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
318 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
319 #ifndef CENTRALDIRINVALID |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
320 #define CENTRALDIRINVALID ((ZPOS64_T)(-1)) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
321 #endif |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
322 |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
323 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
324 Locate the Central directory of a zipfile (at the end, just before |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
325 the global comment) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
326 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
327 local ZPOS64_T unz64local_SearchCentralDir(const zlib_filefunc64_32_def* pzlib_filefunc_def, voidpf filestream) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
328 unsigned char* buf; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
329 ZPOS64_T uSizeFile; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
330 ZPOS64_T uBackRead; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
331 ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
332 ZPOS64_T uPosFound=CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
333 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
334 if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
335 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
336 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
337 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
338 uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
339 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
340 if (uMaxBack>uSizeFile) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
341 uMaxBack = uSizeFile; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
342 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
343 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
344 if (buf==NULL) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
345 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
346 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
347 uBackRead = 4; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
348 while (uBackRead<uMaxBack) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
349 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
350 uLong uReadSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
351 ZPOS64_T uReadPos ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
352 int i; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
353 if (uBackRead+BUFREADCOMMENT>uMaxBack) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
354 uBackRead = uMaxBack; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
355 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
356 uBackRead+=BUFREADCOMMENT; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
357 uReadPos = uSizeFile-uBackRead ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
358 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
359 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
360 (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
361 if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
362 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
363 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
364 if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
365 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
366 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
367 for (i=(int)uReadSize-3; (i--)>0;) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
368 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
369 ((*(buf+i+2))==0x05) && ((*(buf+i+3))==0x06)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
370 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
371 uPosFound = uReadPos+(unsigned)i; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
372 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
373 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
374 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
375 if (uPosFound!=CENTRALDIRINVALID) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
376 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
377 } |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
378 free(buf); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
379 return uPosFound; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
380 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
381 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
382 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
383 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
384 Locate the Central directory 64 of a zipfile (at the end, just before |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
385 the global comment) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
386 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
387 local ZPOS64_T unz64local_SearchCentralDir64(const zlib_filefunc64_32_def* pzlib_filefunc_def, |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
388 voidpf filestream) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
389 unsigned char* buf; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
390 ZPOS64_T uSizeFile; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
391 ZPOS64_T uBackRead; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
392 ZPOS64_T uMaxBack=0xffff; /* maximum size of global comment */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
393 ZPOS64_T uPosFound=CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
394 uLong uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
395 ZPOS64_T relativeOffset; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
396 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
397 if (ZSEEK64(*pzlib_filefunc_def,filestream,0,ZLIB_FILEFUNC_SEEK_END) != 0) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
398 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
399 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
400 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
401 uSizeFile = ZTELL64(*pzlib_filefunc_def,filestream); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
402 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
403 if (uMaxBack>uSizeFile) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
404 uMaxBack = uSizeFile; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
405 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
406 buf = (unsigned char*)ALLOC(BUFREADCOMMENT+4); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
407 if (buf==NULL) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
408 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
409 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
410 uBackRead = 4; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
411 while (uBackRead<uMaxBack) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
412 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
413 uLong uReadSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
414 ZPOS64_T uReadPos; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
415 int i; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
416 if (uBackRead+BUFREADCOMMENT>uMaxBack) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
417 uBackRead = uMaxBack; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
418 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
419 uBackRead+=BUFREADCOMMENT; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
420 uReadPos = uSizeFile-uBackRead ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
421 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
422 uReadSize = ((BUFREADCOMMENT+4) < (uSizeFile-uReadPos)) ? |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
423 (BUFREADCOMMENT+4) : (uLong)(uSizeFile-uReadPos); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
424 if (ZSEEK64(*pzlib_filefunc_def,filestream,uReadPos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
425 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
426 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
427 if (ZREAD64(*pzlib_filefunc_def,filestream,buf,uReadSize)!=uReadSize) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
428 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
429 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
430 for (i=(int)uReadSize-3; (i--)>0;) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
431 if (((*(buf+i))==0x50) && ((*(buf+i+1))==0x4b) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
432 ((*(buf+i+2))==0x06) && ((*(buf+i+3))==0x07)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
433 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
434 uPosFound = uReadPos+(unsigned)i; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
435 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
436 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
437 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
438 if (uPosFound!=CENTRALDIRINVALID) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
439 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
440 } |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
441 free(buf); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
442 if (uPosFound == CENTRALDIRINVALID) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
443 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
444 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
445 /* Zip64 end of central directory locator */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
446 if (ZSEEK64(*pzlib_filefunc_def,filestream, uPosFound,ZLIB_FILEFUNC_SEEK_SET)!=0) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
447 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
448 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
449 /* the signature, already checked */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
450 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
451 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
452 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
453 /* number of the disk with the start of the zip64 end of central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
454 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
455 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
456 if (uL != 0) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
457 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
458 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
459 /* relative offset of the zip64 end of central directory record */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
460 if (unz64local_getLong64(pzlib_filefunc_def,filestream,&relativeOffset)!=UNZ_OK) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
461 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
462 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
463 /* total number of disks */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
464 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
465 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
466 if (uL != 1) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
467 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
468 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
469 /* Goto end of central directory record */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
470 if (ZSEEK64(*pzlib_filefunc_def,filestream, relativeOffset,ZLIB_FILEFUNC_SEEK_SET)!=0) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
471 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
472 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
473 /* the signature */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
474 if (unz64local_getLong(pzlib_filefunc_def,filestream,&uL)!=UNZ_OK) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
475 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
476 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
477 if (uL != 0x06064b50) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
478 return CENTRALDIRINVALID; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
479 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
480 return relativeOffset; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
481 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
482 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
483 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
484 Open a Zip file. path contain the full pathname (by example, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
485 on a Windows NT computer "c:\\test\\zlib114.zip" or on an Unix computer |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
486 "zlib/zlib114.zip". |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
487 If the zipfile cannot be opened (file doesn't exist or in not valid), the |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
488 return value is NULL. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
489 Else, the return value is a unzFile Handle, usable with other function |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
490 of this unzip package. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
491 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
492 local unzFile unzOpenInternal(const void *path, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
493 zlib_filefunc64_32_def* pzlib_filefunc64_32_def, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
494 int is64bitOpenFunction) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
495 unz64_s us; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
496 unz64_s *s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
497 ZPOS64_T central_pos; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
498 uLong uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
499 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
500 uLong number_disk; /* number of the current dist, used for |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
501 spanning ZIP, unsupported, always 0*/ |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
502 uLong number_disk_with_CD; /* number the the disk with central dir, used |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
503 for spanning ZIP, unsupported, always 0*/ |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
504 ZPOS64_T number_entry_CD; /* total number of entries in |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
505 the central dir |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
506 (same than number_entry on nospan) */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
507 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
508 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
509 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
510 if (unz_copyright[0]!=' ') |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
511 return NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
512 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
513 us.z_filefunc.zseek32_file = NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
514 us.z_filefunc.ztell32_file = NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
515 if (pzlib_filefunc64_32_def==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
516 fill_fopen64_filefunc(&us.z_filefunc.zfile_func64); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
517 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
518 us.z_filefunc = *pzlib_filefunc64_32_def; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
519 us.is64bitOpenFunction = is64bitOpenFunction; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
520 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
521 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
522 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
523 us.filestream = ZOPEN64(us.z_filefunc, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
524 path, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
525 ZLIB_FILEFUNC_MODE_READ | |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
526 ZLIB_FILEFUNC_MODE_EXISTING); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
527 if (us.filestream==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
528 return NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
529 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
530 central_pos = unz64local_SearchCentralDir64(&us.z_filefunc,us.filestream); |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
531 if (central_pos!=CENTRALDIRINVALID) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
532 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
533 uLong uS; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
534 ZPOS64_T uL64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
535 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
536 us.isZip64 = 1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
537 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
538 if (ZSEEK64(us.z_filefunc, us.filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
539 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
540 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
541 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
542 /* the signature, already checked */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
543 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
544 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
545 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
546 /* size of zip64 end of central directory record */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
547 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&uL64)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
548 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
549 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
550 /* version made by */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
551 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
552 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
553 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
554 /* version needed to extract */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
555 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uS)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
556 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
557 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
558 /* number of this disk */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
559 if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
560 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
561 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
562 /* number of the disk with the start of the central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
563 if (unz64local_getLong(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
564 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
565 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
566 /* total number of entries in the central directory on this disk */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
567 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.gi.number_entry)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
568 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
569 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
570 /* total number of entries in the central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
571 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&number_entry_CD)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
572 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
573 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
574 if ((number_entry_CD!=us.gi.number_entry) || |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
575 (number_disk_with_CD!=0) || |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
576 (number_disk!=0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
577 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
578 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
579 /* size of the central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
580 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.size_central_dir)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
581 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
582 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
583 /* offset of start of central directory with respect to the |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
584 starting disk number */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
585 if (unz64local_getLong64(&us.z_filefunc, us.filestream,&us.offset_central_dir)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
586 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
587 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
588 us.gi.size_comment = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
589 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
590 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
591 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
592 central_pos = unz64local_SearchCentralDir(&us.z_filefunc,us.filestream); |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
593 if (central_pos==CENTRALDIRINVALID) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
594 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
595 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
596 us.isZip64 = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
597 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
598 if (ZSEEK64(us.z_filefunc, us.filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
599 central_pos,ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
600 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
601 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
602 /* the signature, already checked */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
603 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
604 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
605 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
606 /* number of this disk */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
607 if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
608 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
609 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
610 /* number of the disk with the start of the central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
611 if (unz64local_getShort(&us.z_filefunc, us.filestream,&number_disk_with_CD)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
612 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
613 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
614 /* total number of entries in the central dir on this disk */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
615 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
616 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
617 us.gi.number_entry = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
618 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
619 /* total number of entries in the central dir */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
620 if (unz64local_getShort(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
621 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
622 number_entry_CD = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
623 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
624 if ((number_entry_CD!=us.gi.number_entry) || |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
625 (number_disk_with_CD!=0) || |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
626 (number_disk!=0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
627 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
628 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
629 /* size of the central directory */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
630 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
631 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
632 us.size_central_dir = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
633 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
634 /* offset of start of central directory with respect to the |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
635 starting disk number */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
636 if (unz64local_getLong(&us.z_filefunc, us.filestream,&uL)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
637 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
638 us.offset_central_dir = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
639 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
640 /* zipfile comment length */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
641 if (unz64local_getShort(&us.z_filefunc, us.filestream,&us.gi.size_comment)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
642 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
643 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
644 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
645 if ((central_pos<us.offset_central_dir+us.size_central_dir) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
646 (err==UNZ_OK)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
647 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
648 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
649 if (err!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
650 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
651 ZCLOSE64(us.z_filefunc, us.filestream); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
652 return NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
653 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
654 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
655 us.byte_before_the_zipfile = central_pos - |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
656 (us.offset_central_dir+us.size_central_dir); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
657 us.central_pos = central_pos; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
658 us.pfile_in_zip_read = NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
659 us.encrypted = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
660 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
661 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
662 s=(unz64_s*)ALLOC(sizeof(unz64_s)); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
663 if( s != NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
664 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
665 *s=us; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
666 unzGoToFirstFile((unzFile)s); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
667 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
668 return (unzFile)s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
669 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
670 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
671 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
672 extern unzFile ZEXPORT unzOpen2(const char *path, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
673 zlib_filefunc_def* pzlib_filefunc32_def) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
674 if (pzlib_filefunc32_def != NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
675 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
676 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
677 fill_zlib_filefunc64_32_def_from_filefunc32(&zlib_filefunc64_32_def_fill,pzlib_filefunc32_def); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
678 return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
679 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
680 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
681 return unzOpenInternal(path, NULL, 0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
682 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
683 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
684 extern unzFile ZEXPORT unzOpen2_64(const void *path, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
685 zlib_filefunc64_def* pzlib_filefunc_def) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
686 if (pzlib_filefunc_def != NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
687 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
688 zlib_filefunc64_32_def zlib_filefunc64_32_def_fill; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
689 zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
690 zlib_filefunc64_32_def_fill.ztell32_file = NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
691 zlib_filefunc64_32_def_fill.zseek32_file = NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
692 return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
693 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
694 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
695 return unzOpenInternal(path, NULL, 1); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
696 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
697 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
698 extern unzFile ZEXPORT unzOpen(const char *path) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
699 return unzOpenInternal(path, NULL, 0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
700 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
701 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
702 extern unzFile ZEXPORT unzOpen64(const void *path) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
703 return unzOpenInternal(path, NULL, 1); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
704 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
705 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
706 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
707 Close a ZipFile opened with unzOpen. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
708 If there is files inside the .Zip opened with unzOpenCurrentFile (see later), |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
709 these files MUST be closed with unzCloseCurrentFile before call unzClose. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
710 return UNZ_OK if there is no problem. */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
711 extern int ZEXPORT unzClose(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
712 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
713 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
714 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
715 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
716 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
717 if (s->pfile_in_zip_read!=NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
718 unzCloseCurrentFile(file); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
719 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
720 ZCLOSE64(s->z_filefunc, s->filestream); |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
721 free(s); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
722 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
723 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
724 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
725 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
726 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
727 Write info about the ZipFile in the *pglobal_info structure. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
728 No preparation of the structure is needed |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
729 return UNZ_OK if there is no problem. */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
730 extern int ZEXPORT unzGetGlobalInfo64(unzFile file, unz_global_info64* pglobal_info) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
731 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
732 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
733 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
734 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
735 *pglobal_info=s->gi; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
736 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
737 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
738 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
739 extern int ZEXPORT unzGetGlobalInfo(unzFile file, unz_global_info* pglobal_info32) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
740 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
741 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
742 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
743 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
744 /* to do : check if number_entry is not truncated */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
745 pglobal_info32->number_entry = (uLong)s->gi.number_entry; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
746 pglobal_info32->size_comment = s->gi.size_comment; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
747 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
748 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
749 /* |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
750 Translate date/time from Dos format to tm_unz (readable more easily) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
751 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
752 local void unz64local_DosDateToTmuDate(ZPOS64_T ulDosDate, tm_unz* ptm) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
753 ZPOS64_T uDate; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
754 uDate = (ZPOS64_T)(ulDosDate>>16); |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
755 ptm->tm_mday = (int)(uDate&0x1f) ; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
756 ptm->tm_mon = (int)((((uDate)&0x1E0)/0x20)-1) ; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
757 ptm->tm_year = (int)(((uDate&0x0FE00)/0x0200)+1980) ; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
758 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
759 ptm->tm_hour = (int) ((ulDosDate &0xF800)/0x800); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
760 ptm->tm_min = (int) ((ulDosDate&0x7E0)/0x20) ; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
761 ptm->tm_sec = (int) (2*(ulDosDate&0x1f)) ; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
762 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
763 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
764 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
765 Get Info about the current file in the zipfile, with internal only info |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
766 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
767 local int unz64local_GetCurrentFileInfoInternal(unzFile file, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
768 unz_file_info64 *pfile_info, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
769 unz_file_info64_internal |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
770 *pfile_info_internal, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
771 char *szFileName, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
772 uLong fileNameBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
773 void *extraField, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
774 uLong extraFieldBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
775 char *szComment, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
776 uLong commentBufferSize) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
777 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
778 unz_file_info64 file_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
779 unz_file_info64_internal file_info_internal; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
780 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
781 uLong uMagic; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
782 long lSeek=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
783 uLong uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
784 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
785 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
786 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
787 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
788 if (ZSEEK64(s->z_filefunc, s->filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
789 s->pos_in_central_dir+s->byte_before_the_zipfile, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
790 ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
791 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
792 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
793 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
794 /* we check the magic */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
795 if (err==UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
796 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
797 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
798 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
799 else if (uMagic!=0x02014b50) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
800 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
801 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
802 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
803 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
804 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
805 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
806 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.version_needed) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
807 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
808 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
809 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.flag) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
810 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
811 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
812 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.compression_method) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
813 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
814 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
815 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.dosDate) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
816 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
817 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
818 unz64local_DosDateToTmuDate(file_info.dosDate,&file_info.tmu_date); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
819 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
820 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.crc) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
821 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
822 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
823 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
824 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
825 file_info.compressed_size = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
826 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
827 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
828 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
829 file_info.uncompressed_size = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
830 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
831 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_filename) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
832 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
833 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
834 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_extra) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
835 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
836 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
837 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.size_file_comment) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
838 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
839 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
840 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
841 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
842 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
843 if (unz64local_getShort(&s->z_filefunc, s->filestream,&file_info.internal_fa) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
844 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
845 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
846 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.external_fa) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
847 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
848 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
849 // relative offset of local header |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
850 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uL) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
851 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
852 file_info_internal.offset_curfile = uL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
853 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
854 lSeek+=file_info.size_filename; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
855 if ((err==UNZ_OK) && (szFileName!=NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
856 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
857 uLong uSizeRead ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
858 if (file_info.size_filename<fileNameBufferSize) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
859 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
860 *(szFileName+file_info.size_filename)='\0'; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
861 uSizeRead = file_info.size_filename; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
862 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
863 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
864 uSizeRead = fileNameBufferSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
865 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
866 if ((file_info.size_filename>0) && (fileNameBufferSize>0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
867 if (ZREAD64(s->z_filefunc, s->filestream,szFileName,uSizeRead)!=uSizeRead) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
868 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
869 lSeek -= uSizeRead; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
870 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
871 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
872 // Read extrafield |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
873 if ((err==UNZ_OK) && (extraField!=NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
874 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
875 ZPOS64_T uSizeRead ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
876 if (file_info.size_file_extra<extraFieldBufferSize) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
877 uSizeRead = file_info.size_file_extra; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
878 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
879 uSizeRead = extraFieldBufferSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
880 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
881 if (lSeek!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
882 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
883 if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
884 lSeek=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
885 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
886 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
887 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
888 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
889 if ((file_info.size_file_extra>0) && (extraFieldBufferSize>0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
890 if (ZREAD64(s->z_filefunc, s->filestream,extraField,(uLong)uSizeRead)!=uSizeRead) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
891 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
892 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
893 lSeek += file_info.size_file_extra - (uLong)uSizeRead; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
894 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
895 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
896 lSeek += file_info.size_file_extra; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
897 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
898 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
899 if ((err==UNZ_OK) && (file_info.size_file_extra != 0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
900 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
901 uLong acc = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
902 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
903 // since lSeek now points to after the extra field we need to move back |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
904 lSeek -= file_info.size_file_extra; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
905 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
906 if (lSeek!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
907 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
908 if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
909 lSeek=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
910 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
911 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
912 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
913 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
914 while(acc < file_info.size_file_extra) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
915 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
916 uLong headerId; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
917 uLong dataSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
918 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
919 if (unz64local_getShort(&s->z_filefunc, s->filestream,&headerId) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
920 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
921 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
922 if (unz64local_getShort(&s->z_filefunc, s->filestream,&dataSize) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
923 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
924 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
925 /* ZIP64 extra fields */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
926 if (headerId == 0x0001) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
927 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
928 if(file_info.uncompressed_size == MAXU32) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
929 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
930 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.uncompressed_size) != UNZ_OK) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
931 err=UNZ_ERRNO; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
932 } |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
933 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
934 if(file_info.compressed_size == MAXU32) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
935 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
936 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info.compressed_size) != UNZ_OK) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
937 err=UNZ_ERRNO; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
938 } |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
939 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
940 if(file_info_internal.offset_curfile == MAXU32) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
941 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
942 /* Relative Header offset */ |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
943 if (unz64local_getLong64(&s->z_filefunc, s->filestream,&file_info_internal.offset_curfile) != UNZ_OK) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
944 err=UNZ_ERRNO; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
945 } |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
946 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
947 if(file_info.disk_num_start == 0xffff) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
948 { |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
949 /* Disk Start Number */ |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
950 if (unz64local_getLong(&s->z_filefunc, s->filestream,&file_info.disk_num_start) != UNZ_OK) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
951 err=UNZ_ERRNO; |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
952 } |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
953 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
954 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
955 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
956 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
957 if (ZSEEK64(s->z_filefunc, s->filestream,dataSize,ZLIB_FILEFUNC_SEEK_CUR)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
958 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
959 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
960 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
961 acc += 2 + 2 + dataSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
962 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
963 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
964 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
965 if ((err==UNZ_OK) && (szComment!=NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
966 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
967 uLong uSizeRead ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
968 if (file_info.size_file_comment<commentBufferSize) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
969 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
970 *(szComment+file_info.size_file_comment)='\0'; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
971 uSizeRead = file_info.size_file_comment; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
972 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
973 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
974 uSizeRead = commentBufferSize; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
975 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
976 if (lSeek!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
977 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
978 if (ZSEEK64(s->z_filefunc, s->filestream,(ZPOS64_T)lSeek,ZLIB_FILEFUNC_SEEK_CUR)==0) |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
979 lSeek=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
980 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
981 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
982 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
983 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
984 if ((file_info.size_file_comment>0) && (commentBufferSize>0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
985 if (ZREAD64(s->z_filefunc, s->filestream,szComment,uSizeRead)!=uSizeRead) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
986 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
987 lSeek+=file_info.size_file_comment - uSizeRead; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
988 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
989 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
990 lSeek+=file_info.size_file_comment; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
991 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
992 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
993 if ((err==UNZ_OK) && (pfile_info!=NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
994 *pfile_info=file_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
995 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
996 if ((err==UNZ_OK) && (pfile_info_internal!=NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
997 *pfile_info_internal=file_info_internal; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
998 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
999 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1000 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1001 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1002 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1003 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1004 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1005 Write info about the ZipFile in the *pglobal_info structure. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1006 No preparation of the structure is needed |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1007 return UNZ_OK if there is no problem. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1008 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1009 extern int ZEXPORT unzGetCurrentFileInfo64(unzFile file, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1010 unz_file_info64 * pfile_info, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1011 char * szFileName, uLong fileNameBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1012 void *extraField, uLong extraFieldBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1013 char* szComment, uLong commentBufferSize) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1014 return unz64local_GetCurrentFileInfoInternal(file,pfile_info,NULL, |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1015 szFileName,fileNameBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1016 extraField,extraFieldBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1017 szComment,commentBufferSize); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1018 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1019 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1020 extern int ZEXPORT unzGetCurrentFileInfo(unzFile file, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1021 unz_file_info * pfile_info, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1022 char * szFileName, uLong fileNameBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1023 void *extraField, uLong extraFieldBufferSize, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1024 char* szComment, uLong commentBufferSize) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1025 int err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1026 unz_file_info64 file_info64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1027 err = unz64local_GetCurrentFileInfoInternal(file,&file_info64,NULL, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1028 szFileName,fileNameBufferSize, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1029 extraField,extraFieldBufferSize, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1030 szComment,commentBufferSize); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1031 if ((err==UNZ_OK) && (pfile_info != NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1032 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1033 pfile_info->version = file_info64.version; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1034 pfile_info->version_needed = file_info64.version_needed; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1035 pfile_info->flag = file_info64.flag; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1036 pfile_info->compression_method = file_info64.compression_method; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1037 pfile_info->dosDate = file_info64.dosDate; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1038 pfile_info->crc = file_info64.crc; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1039 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1040 pfile_info->size_filename = file_info64.size_filename; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1041 pfile_info->size_file_extra = file_info64.size_file_extra; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1042 pfile_info->size_file_comment = file_info64.size_file_comment; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1043 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1044 pfile_info->disk_num_start = file_info64.disk_num_start; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1045 pfile_info->internal_fa = file_info64.internal_fa; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1046 pfile_info->external_fa = file_info64.external_fa; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1047 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1048 pfile_info->tmu_date = file_info64.tmu_date; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1049 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1050 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1051 pfile_info->compressed_size = (uLong)file_info64.compressed_size; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1052 pfile_info->uncompressed_size = (uLong)file_info64.uncompressed_size; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1053 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1054 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1055 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1056 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1057 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1058 Set the current file of the zipfile to the first file. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1059 return UNZ_OK if there is no problem |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1060 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1061 extern int ZEXPORT unzGoToFirstFile(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1062 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1063 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1064 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1065 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1066 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1067 s->pos_in_central_dir=s->offset_central_dir; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1068 s->num_file=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1069 err=unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1070 &s->cur_file_info_internal, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1071 NULL,0,NULL,0,NULL,0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1072 s->current_file_ok = (err == UNZ_OK); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1073 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1074 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1075 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1076 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1077 Set the current file of the zipfile to the next file. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1078 return UNZ_OK if there is no problem |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1079 return UNZ_END_OF_LIST_OF_FILE if the actual file was the latest. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1080 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1081 extern int ZEXPORT unzGoToNextFile(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1082 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1083 int err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1084 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1085 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1086 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1087 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1088 if (!s->current_file_ok) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1089 return UNZ_END_OF_LIST_OF_FILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1090 if (s->gi.number_entry != 0xffff) /* 2^16 files overflow hack */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1091 if (s->num_file+1==s->gi.number_entry) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1092 return UNZ_END_OF_LIST_OF_FILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1093 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1094 s->pos_in_central_dir += SIZECENTRALDIRITEM + s->cur_file_info.size_filename + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1095 s->cur_file_info.size_file_extra + s->cur_file_info.size_file_comment ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1096 s->num_file++; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1097 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1098 &s->cur_file_info_internal, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1099 NULL,0,NULL,0,NULL,0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1100 s->current_file_ok = (err == UNZ_OK); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1101 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1102 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1103 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1104 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1105 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1106 Try locate the file szFileName in the zipfile. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1107 For the iCaseSensitivity signification, see unzStringFileNameCompare |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1108 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1109 return value : |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1110 UNZ_OK if the file is found. It becomes the current file. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1111 UNZ_END_OF_LIST_OF_FILE if the file is not found |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1112 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1113 extern int ZEXPORT unzLocateFile(unzFile file, const char *szFileName, int iCaseSensitivity) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1114 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1115 int err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1116 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1117 /* We remember the 'current' position in the file so that we can jump |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1118 * back there if we fail. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1119 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1120 unz_file_info64 cur_file_infoSaved; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1121 unz_file_info64_internal cur_file_info_internalSaved; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1122 ZPOS64_T num_fileSaved; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1123 ZPOS64_T pos_in_central_dirSaved; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1124 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1125 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1126 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1127 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1128 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1129 if (strlen(szFileName)>=UNZ_MAXFILENAMEINZIP) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1130 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1131 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1132 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1133 if (!s->current_file_ok) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1134 return UNZ_END_OF_LIST_OF_FILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1135 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1136 /* Save the current state */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1137 num_fileSaved = s->num_file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1138 pos_in_central_dirSaved = s->pos_in_central_dir; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1139 cur_file_infoSaved = s->cur_file_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1140 cur_file_info_internalSaved = s->cur_file_info_internal; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1141 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1142 err = unzGoToFirstFile(file); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1143 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1144 while (err == UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1145 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1146 char szCurrentFileName[UNZ_MAXFILENAMEINZIP+1]; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1147 err = unzGetCurrentFileInfo64(file,NULL, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1148 szCurrentFileName,sizeof(szCurrentFileName)-1, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1149 NULL,0,NULL,0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1150 if (err == UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1151 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1152 if (unzStringFileNameCompare(szCurrentFileName, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1153 szFileName,iCaseSensitivity)==0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1154 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1155 err = unzGoToNextFile(file); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1156 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1157 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1158 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1159 /* We failed, so restore the state of the 'current file' to where we |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1160 * were. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1161 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1162 s->num_file = num_fileSaved ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1163 s->pos_in_central_dir = pos_in_central_dirSaved ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1164 s->cur_file_info = cur_file_infoSaved; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1165 s->cur_file_info_internal = cur_file_info_internalSaved; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1166 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1167 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1168 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1169 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1170 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1171 /////////////////////////////////////////// |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1172 // Contributed by Ryan Haksi (mailto://cryogen@infoserve.net) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1173 // I need random access |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1174 // |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1175 // Further optimization could be realized by adding an ability |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1176 // to cache the directory in memory. The goal being a single |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1177 // comprehensive file read to put the file I need in a memory. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1178 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1179 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1180 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1181 typedef struct unz_file_pos_s |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1182 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1183 ZPOS64_T pos_in_zip_directory; // offset in file |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1184 ZPOS64_T num_of_file; // # of file |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1185 } unz_file_pos; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1186 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1187 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1188 extern int ZEXPORT unzGetFilePos64(unzFile file, unz64_file_pos* file_pos) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1189 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1190 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1191 if (file==NULL || file_pos==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1192 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1193 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1194 if (!s->current_file_ok) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1195 return UNZ_END_OF_LIST_OF_FILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1196 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1197 file_pos->pos_in_zip_directory = s->pos_in_central_dir; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1198 file_pos->num_of_file = s->num_file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1199 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1200 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1201 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1202 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1203 extern int ZEXPORT unzGetFilePos(unzFile file, unz_file_pos* file_pos) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1204 unz64_file_pos file_pos64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1205 int err = unzGetFilePos64(file,&file_pos64); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1206 if (err==UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1207 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1208 file_pos->pos_in_zip_directory = (uLong)file_pos64.pos_in_zip_directory; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1209 file_pos->num_of_file = (uLong)file_pos64.num_of_file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1210 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1211 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1212 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1213 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1214 extern int ZEXPORT unzGoToFilePos64(unzFile file, const unz64_file_pos* file_pos) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1215 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1216 int err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1217 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1218 if (file==NULL || file_pos==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1219 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1220 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1221 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1222 /* jump to the right spot */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1223 s->pos_in_central_dir = file_pos->pos_in_zip_directory; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1224 s->num_file = file_pos->num_of_file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1225 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1226 /* set the current file */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1227 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1228 &s->cur_file_info_internal, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1229 NULL,0,NULL,0,NULL,0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1230 /* return results */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1231 s->current_file_ok = (err == UNZ_OK); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1232 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1233 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1234 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1235 extern int ZEXPORT unzGoToFilePos(unzFile file, unz_file_pos* file_pos) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1236 unz64_file_pos file_pos64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1237 if (file_pos == NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1238 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1239 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1240 file_pos64.pos_in_zip_directory = file_pos->pos_in_zip_directory; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1241 file_pos64.num_of_file = file_pos->num_of_file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1242 return unzGoToFilePos64(file,&file_pos64); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1243 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1244 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1245 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1246 // Unzip Helper Functions - should be here? |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1247 /////////////////////////////////////////// |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1248 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1249 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1250 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1251 Read the local header of the current zipfile |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1252 Check the coherency of the local header and info in the end of central |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1253 directory about this file |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1254 store in *piSizeVar the size of extra info in local header |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1255 (filename and size of extra field data) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1256 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1257 local int unz64local_CheckCurrentFileCoherencyHeader(unz64_s* s, uInt* piSizeVar, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1258 ZPOS64_T * poffset_local_extrafield, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1259 uInt * psize_local_extrafield) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1260 uLong uMagic,uData,uFlags; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1261 uLong size_filename; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1262 uLong size_extra_field; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1263 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1264 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1265 *piSizeVar = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1266 *poffset_local_extrafield = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1267 *psize_local_extrafield = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1268 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1269 if (ZSEEK64(s->z_filefunc, s->filestream,s->cur_file_info_internal.offset_curfile + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1270 s->byte_before_the_zipfile,ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1271 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1272 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1273 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1274 if (err==UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1275 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1276 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uMagic) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1277 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1278 else if (uMagic!=0x04034b50) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1279 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1280 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1281 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1282 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1283 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1284 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1285 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.wVersion)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1286 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1287 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1288 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uFlags) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1289 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1290 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1291 if (unz64local_getShort(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1292 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1293 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.compression_method)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1294 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1295 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1296 if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1297 /* #ifdef HAVE_BZIP2 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1298 (s->cur_file_info.compression_method!=Z_BZIP2ED) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1299 /* #endif */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1300 (s->cur_file_info.compression_method!=Z_DEFLATED)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1301 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1302 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1303 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* date/time */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1304 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1305 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1306 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* crc */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1307 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1308 else if ((err==UNZ_OK) && (uData!=s->cur_file_info.crc) && ((uFlags & 8)==0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1309 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1310 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1311 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size compr */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1312 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1313 else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.compressed_size) && ((uFlags & 8)==0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1314 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1315 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1316 if (unz64local_getLong(&s->z_filefunc, s->filestream,&uData) != UNZ_OK) /* size uncompr */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1317 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1318 else if (uData != 0xFFFFFFFF && (err==UNZ_OK) && (uData!=s->cur_file_info.uncompressed_size) && ((uFlags & 8)==0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1319 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1320 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1321 if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_filename) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1322 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1323 else if ((err==UNZ_OK) && (size_filename!=s->cur_file_info.size_filename)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1324 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1325 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1326 *piSizeVar += (uInt)size_filename; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1327 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1328 if (unz64local_getShort(&s->z_filefunc, s->filestream,&size_extra_field) != UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1329 err=UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1330 *poffset_local_extrafield= s->cur_file_info_internal.offset_curfile + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1331 SIZEZIPLOCALHEADER + size_filename; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1332 *psize_local_extrafield = (uInt)size_extra_field; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1333 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1334 *piSizeVar += (uInt)size_extra_field; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1335 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1336 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1337 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1338 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1339 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1340 Open for reading data the current file in the zipfile. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1341 If there is no error and the file is opened, the return value is UNZ_OK. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1342 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1343 extern int ZEXPORT unzOpenCurrentFile3(unzFile file, int* method, |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1344 int* level, int raw, const char* password) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1345 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1346 uInt iSizeVar; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1347 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1348 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1349 ZPOS64_T offset_local_extrafield; /* offset of the local extra field */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1350 uInt size_local_extrafield; /* size of the local extra field */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1351 # ifndef NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1352 char source[12]; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1353 # else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1354 if (password != NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1355 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1356 # endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1357 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1358 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1359 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1360 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1361 if (!s->current_file_ok) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1362 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1363 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1364 if (s->pfile_in_zip_read != NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1365 unzCloseCurrentFile(file); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1366 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1367 if (unz64local_CheckCurrentFileCoherencyHeader(s,&iSizeVar, &offset_local_extrafield,&size_local_extrafield)!=UNZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1368 return UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1369 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1370 pfile_in_zip_read_info = (file_in_zip64_read_info_s*)ALLOC(sizeof(file_in_zip64_read_info_s)); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1371 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1372 return UNZ_INTERNALERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1373 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1374 pfile_in_zip_read_info->read_buffer=(char*)ALLOC(UNZ_BUFSIZE); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1375 pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1376 pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1377 pfile_in_zip_read_info->pos_local_extrafield=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1378 pfile_in_zip_read_info->raw=raw; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1379 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1380 if (pfile_in_zip_read_info->read_buffer==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1381 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1382 free(pfile_in_zip_read_info); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1383 return UNZ_INTERNALERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1384 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1385 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1386 pfile_in_zip_read_info->stream_initialised=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1387 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1388 if (method!=NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1389 *method = (int)s->cur_file_info.compression_method; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1390 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1391 if (level!=NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1392 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1393 *level = 6; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1394 switch (s->cur_file_info.flag & 0x06) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1395 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1396 case 6 : *level = 1; break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1397 case 4 : *level = 2; break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1398 case 2 : *level = 9; break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1399 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1400 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1401 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1402 if ((s->cur_file_info.compression_method!=0) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1403 /* #ifdef HAVE_BZIP2 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1404 (s->cur_file_info.compression_method!=Z_BZIP2ED) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1405 /* #endif */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1406 (s->cur_file_info.compression_method!=Z_DEFLATED)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1407 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1408 err=UNZ_BADZIPFILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1409 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1410 pfile_in_zip_read_info->crc32_wait=s->cur_file_info.crc; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1411 pfile_in_zip_read_info->crc32=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1412 pfile_in_zip_read_info->total_out_64=0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1413 pfile_in_zip_read_info->compression_method = s->cur_file_info.compression_method; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1414 pfile_in_zip_read_info->filestream=s->filestream; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1415 pfile_in_zip_read_info->z_filefunc=s->z_filefunc; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1416 pfile_in_zip_read_info->byte_before_the_zipfile=s->byte_before_the_zipfile; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1417 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1418 pfile_in_zip_read_info->stream.total_out = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1419 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1420 if ((s->cur_file_info.compression_method==Z_BZIP2ED) && (!raw)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1421 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1422 #ifdef HAVE_BZIP2 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1423 pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1424 pfile_in_zip_read_info->bstream.bzfree = (free_func)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1425 pfile_in_zip_read_info->bstream.opaque = (voidpf)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1426 pfile_in_zip_read_info->bstream.state = (voidpf)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1427 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1428 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1429 pfile_in_zip_read_info->stream.zfree = (free_func)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1430 pfile_in_zip_read_info->stream.opaque = (voidpf)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1431 pfile_in_zip_read_info->stream.next_in = (voidpf)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1432 pfile_in_zip_read_info->stream.avail_in = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1433 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1434 err=BZ2_bzDecompressInit(&pfile_in_zip_read_info->bstream, 0, 0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1435 if (err == Z_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1436 pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1437 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1438 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1439 free(pfile_in_zip_read_info->read_buffer); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1440 free(pfile_in_zip_read_info); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1441 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1442 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1443 #else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1444 pfile_in_zip_read_info->raw=1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1445 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1446 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1447 else if ((s->cur_file_info.compression_method==Z_DEFLATED) && (!raw)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1448 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1449 pfile_in_zip_read_info->stream.zalloc = (alloc_func)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1450 pfile_in_zip_read_info->stream.zfree = (free_func)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1451 pfile_in_zip_read_info->stream.opaque = (voidpf)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1452 pfile_in_zip_read_info->stream.next_in = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1453 pfile_in_zip_read_info->stream.avail_in = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1454 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1455 err=inflateInit2(&pfile_in_zip_read_info->stream, -MAX_WBITS); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1456 if (err == Z_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1457 pfile_in_zip_read_info->stream_initialised=Z_DEFLATED; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1458 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1459 { |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1460 free(pfile_in_zip_read_info->read_buffer); |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1461 free(pfile_in_zip_read_info); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1462 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1463 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1464 /* windowBits is passed < 0 to tell that there is no zlib header. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1465 * Note that in this case inflate *requires* an extra "dummy" byte |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1466 * after the compressed stream in order to complete decompression and |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1467 * return Z_STREAM_END. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1468 * In unzip, i don't wait absolutely Z_STREAM_END because I known the |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1469 * size of both compressed and uncompressed data |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1470 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1471 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1472 pfile_in_zip_read_info->rest_read_compressed = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1473 s->cur_file_info.compressed_size ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1474 pfile_in_zip_read_info->rest_read_uncompressed = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1475 s->cur_file_info.uncompressed_size ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1476 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1477 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1478 pfile_in_zip_read_info->pos_in_zipfile = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1479 s->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1480 iSizeVar; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1481 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1482 pfile_in_zip_read_info->stream.avail_in = (uInt)0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1483 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1484 s->pfile_in_zip_read = pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1485 s->encrypted = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1486 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1487 # ifndef NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1488 if (password != NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1489 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1490 int i; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1491 s->pcrc_32_tab = get_crc_table(); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1492 init_keys(password,s->keys,s->pcrc_32_tab); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1493 if (ZSEEK64(s->z_filefunc, s->filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1494 s->pfile_in_zip_read->pos_in_zipfile + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1495 s->pfile_in_zip_read->byte_before_the_zipfile, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1496 SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1497 return UNZ_INTERNALERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1498 if(ZREAD64(s->z_filefunc, s->filestream,source, 12)<12) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1499 return UNZ_INTERNALERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1500 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1501 for (i = 0; i<12; i++) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1502 zdecode(s->keys,s->pcrc_32_tab,source[i]); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1503 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1504 s->pfile_in_zip_read->pos_in_zipfile+=12; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1505 s->encrypted=1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1506 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1507 # endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1508 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1509 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1510 return UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1511 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1512 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1513 extern int ZEXPORT unzOpenCurrentFile(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1514 return unzOpenCurrentFile3(file, NULL, NULL, 0, NULL); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1515 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1516 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1517 extern int ZEXPORT unzOpenCurrentFilePassword(unzFile file, const char* password) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1518 return unzOpenCurrentFile3(file, NULL, NULL, 0, password); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1519 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1520 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1521 extern int ZEXPORT unzOpenCurrentFile2(unzFile file, int* method, int* level, int raw) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1522 return unzOpenCurrentFile3(file, method, level, raw, NULL); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1523 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1524 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1525 /** Addition for GDAL : START */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1526 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1527 extern ZPOS64_T ZEXPORT unzGetCurrentFileZStreamPos64(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1528 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1529 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1530 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1531 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1532 return 0; //UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1533 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1534 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1535 return 0; //UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1536 return pfile_in_zip_read_info->pos_in_zipfile + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1537 pfile_in_zip_read_info->byte_before_the_zipfile; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1538 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1539 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1540 /** Addition for GDAL : END */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1541 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1542 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1543 Read bytes from the current file. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1544 buf contain buffer where data must be copied |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1545 len the size of buf. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1546 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1547 return the number of byte copied if some bytes are copied |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1548 return 0 if the end of file was reached |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1549 return <0 with error code if there is an error |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1550 (UNZ_ERRNO for IO error, or zLib error for uncompress error) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1551 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1552 extern int ZEXPORT unzReadCurrentFile(unzFile file, voidp buf, unsigned len) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1553 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1554 uInt iRead = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1555 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1556 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1557 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1558 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1559 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1560 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1561 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1562 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1563 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1564 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1565 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1566 if (pfile_in_zip_read_info->read_buffer == NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1567 return UNZ_END_OF_LIST_OF_FILE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1568 if (len==0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1569 return 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1570 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1571 pfile_in_zip_read_info->stream.next_out = (Bytef*)buf; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1572 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1573 pfile_in_zip_read_info->stream.avail_out = (uInt)len; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1574 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1575 if ((len>pfile_in_zip_read_info->rest_read_uncompressed) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1576 (!(pfile_in_zip_read_info->raw))) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1577 pfile_in_zip_read_info->stream.avail_out = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1578 (uInt)pfile_in_zip_read_info->rest_read_uncompressed; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1579 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1580 if ((len>pfile_in_zip_read_info->rest_read_compressed+ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1581 pfile_in_zip_read_info->stream.avail_in) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1582 (pfile_in_zip_read_info->raw)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1583 pfile_in_zip_read_info->stream.avail_out = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1584 (uInt)pfile_in_zip_read_info->rest_read_compressed+ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1585 pfile_in_zip_read_info->stream.avail_in; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1586 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1587 while (pfile_in_zip_read_info->stream.avail_out>0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1588 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1589 if ((pfile_in_zip_read_info->stream.avail_in==0) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1590 (pfile_in_zip_read_info->rest_read_compressed>0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1591 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1592 uInt uReadThis = UNZ_BUFSIZE; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1593 if (pfile_in_zip_read_info->rest_read_compressed<uReadThis) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1594 uReadThis = (uInt)pfile_in_zip_read_info->rest_read_compressed; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1595 if (uReadThis == 0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1596 return UNZ_EOF; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1597 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1598 pfile_in_zip_read_info->filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1599 pfile_in_zip_read_info->pos_in_zipfile + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1600 pfile_in_zip_read_info->byte_before_the_zipfile, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1601 ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1602 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1603 if (ZREAD64(pfile_in_zip_read_info->z_filefunc, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1604 pfile_in_zip_read_info->filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1605 pfile_in_zip_read_info->read_buffer, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1606 uReadThis)!=uReadThis) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1607 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1608 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1609 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1610 # ifndef NOUNCRYPT |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1611 if(s->encrypted) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1612 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1613 uInt i; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1614 for(i=0;i<uReadThis;i++) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1615 pfile_in_zip_read_info->read_buffer[i] = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1616 zdecode(s->keys,s->pcrc_32_tab, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1617 pfile_in_zip_read_info->read_buffer[i]); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1618 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1619 # endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1620 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1621 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1622 pfile_in_zip_read_info->pos_in_zipfile += uReadThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1623 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1624 pfile_in_zip_read_info->rest_read_compressed-=uReadThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1625 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1626 pfile_in_zip_read_info->stream.next_in = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1627 (Bytef*)pfile_in_zip_read_info->read_buffer; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1628 pfile_in_zip_read_info->stream.avail_in = (uInt)uReadThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1629 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1630 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1631 if ((pfile_in_zip_read_info->compression_method==0) || (pfile_in_zip_read_info->raw)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1632 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1633 uInt uDoCopy,i ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1634 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1635 if ((pfile_in_zip_read_info->stream.avail_in == 0) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1636 (pfile_in_zip_read_info->rest_read_compressed == 0)) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1637 return (iRead==0) ? UNZ_EOF : (int)iRead; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1638 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1639 if (pfile_in_zip_read_info->stream.avail_out < |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1640 pfile_in_zip_read_info->stream.avail_in) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1641 uDoCopy = pfile_in_zip_read_info->stream.avail_out ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1642 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1643 uDoCopy = pfile_in_zip_read_info->stream.avail_in ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1644 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1645 for (i=0;i<uDoCopy;i++) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1646 *(pfile_in_zip_read_info->stream.next_out+i) = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1647 *(pfile_in_zip_read_info->stream.next_in+i); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1648 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1649 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1650 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1651 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1652 pfile_in_zip_read_info->stream.next_out, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1653 uDoCopy); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1654 pfile_in_zip_read_info->rest_read_uncompressed-=uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1655 pfile_in_zip_read_info->stream.avail_in -= uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1656 pfile_in_zip_read_info->stream.avail_out -= uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1657 pfile_in_zip_read_info->stream.next_out += uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1658 pfile_in_zip_read_info->stream.next_in += uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1659 pfile_in_zip_read_info->stream.total_out += uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1660 iRead += uDoCopy; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1661 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1662 else if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1663 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1664 #ifdef HAVE_BZIP2 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1665 uLong uTotalOutBefore,uTotalOutAfter; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1666 const Bytef *bufBefore; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1667 uLong uOutThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1668 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1669 pfile_in_zip_read_info->bstream.next_in = (char*)pfile_in_zip_read_info->stream.next_in; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1670 pfile_in_zip_read_info->bstream.avail_in = pfile_in_zip_read_info->stream.avail_in; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1671 pfile_in_zip_read_info->bstream.total_in_lo32 = pfile_in_zip_read_info->stream.total_in; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1672 pfile_in_zip_read_info->bstream.total_in_hi32 = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1673 pfile_in_zip_read_info->bstream.next_out = (char*)pfile_in_zip_read_info->stream.next_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1674 pfile_in_zip_read_info->bstream.avail_out = pfile_in_zip_read_info->stream.avail_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1675 pfile_in_zip_read_info->bstream.total_out_lo32 = pfile_in_zip_read_info->stream.total_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1676 pfile_in_zip_read_info->bstream.total_out_hi32 = 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1677 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1678 uTotalOutBefore = pfile_in_zip_read_info->bstream.total_out_lo32; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1679 bufBefore = (const Bytef *)pfile_in_zip_read_info->bstream.next_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1680 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1681 err=BZ2_bzDecompress(&pfile_in_zip_read_info->bstream); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1682 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1683 uTotalOutAfter = pfile_in_zip_read_info->bstream.total_out_lo32; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1684 uOutThis = uTotalOutAfter-uTotalOutBefore; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1685 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1686 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1687 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1688 pfile_in_zip_read_info->crc32 = crc32(pfile_in_zip_read_info->crc32,bufBefore, (uInt)(uOutThis)); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1689 pfile_in_zip_read_info->rest_read_uncompressed -= uOutThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1690 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1691 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1692 pfile_in_zip_read_info->stream.next_in = (Bytef*)pfile_in_zip_read_info->bstream.next_in; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1693 pfile_in_zip_read_info->stream.avail_in = pfile_in_zip_read_info->bstream.avail_in; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1694 pfile_in_zip_read_info->stream.total_in = pfile_in_zip_read_info->bstream.total_in_lo32; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1695 pfile_in_zip_read_info->stream.next_out = (Bytef*)pfile_in_zip_read_info->bstream.next_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1696 pfile_in_zip_read_info->stream.avail_out = pfile_in_zip_read_info->bstream.avail_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1697 pfile_in_zip_read_info->stream.total_out = pfile_in_zip_read_info->bstream.total_out_lo32; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1698 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1699 if (err==BZ_STREAM_END) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1700 return (iRead==0) ? UNZ_EOF : iRead; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1701 if (err!=BZ_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1702 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1703 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1704 } // end Z_BZIP2ED |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1705 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1706 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1707 ZPOS64_T uTotalOutBefore,uTotalOutAfter; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1708 const Bytef *bufBefore; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1709 ZPOS64_T uOutThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1710 int flush=Z_SYNC_FLUSH; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1711 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1712 uTotalOutBefore = pfile_in_zip_read_info->stream.total_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1713 bufBefore = pfile_in_zip_read_info->stream.next_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1714 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1715 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1716 if ((pfile_in_zip_read_info->rest_read_uncompressed == |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1717 pfile_in_zip_read_info->stream.avail_out) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1718 (pfile_in_zip_read_info->rest_read_compressed == 0)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1719 flush = Z_FINISH; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1720 */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1721 err=inflate(&pfile_in_zip_read_info->stream,flush); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1722 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1723 if ((err>=0) && (pfile_in_zip_read_info->stream.msg!=NULL)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1724 err = Z_DATA_ERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1725 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1726 uTotalOutAfter = pfile_in_zip_read_info->stream.total_out; |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1727 /* Detect overflow, because z_stream.total_out is uLong (32 bits) */ |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1728 if (uTotalOutAfter<uTotalOutBefore) |
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1729 uTotalOutAfter += 1LL << 32; /* Add maximum value of uLong + 1 */ |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1730 uOutThis = uTotalOutAfter-uTotalOutBefore; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1731 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1732 pfile_in_zip_read_info->total_out_64 = pfile_in_zip_read_info->total_out_64 + uOutThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1733 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1734 pfile_in_zip_read_info->crc32 = |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1735 crc32(pfile_in_zip_read_info->crc32,bufBefore, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1736 (uInt)(uOutThis)); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1737 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1738 pfile_in_zip_read_info->rest_read_uncompressed -= |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1739 uOutThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1740 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1741 iRead += (uInt)(uTotalOutAfter - uTotalOutBefore); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1742 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1743 if (err==Z_STREAM_END) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1744 return (iRead==0) ? UNZ_EOF : (int)iRead; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1745 if (err!=Z_OK) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1746 break; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1747 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1748 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1749 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1750 if (err==Z_OK) |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1751 return (int)iRead; |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1752 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1753 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1754 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1755 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1756 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1757 Give the current position in uncompressed data |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1758 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1759 extern z_off_t ZEXPORT unztell(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1760 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1761 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1762 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1763 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1764 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1765 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1766 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1767 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1768 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1769 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1770 return (z_off_t)pfile_in_zip_read_info->stream.total_out; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1771 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1772 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1773 extern ZPOS64_T ZEXPORT unztell64(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1774 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1775 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1776 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1777 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1778 return (ZPOS64_T)-1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1779 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1780 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1781 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1782 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1783 return (ZPOS64_T)-1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1784 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1785 return pfile_in_zip_read_info->total_out_64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1786 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1787 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1788 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1789 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1790 return 1 if the end of file was reached, 0 elsewhere |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1791 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1792 extern int ZEXPORT unzeof(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1793 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1794 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1795 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1796 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1797 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1798 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1799 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1800 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1801 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1802 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1803 if (pfile_in_zip_read_info->rest_read_uncompressed == 0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1804 return 1; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1805 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1806 return 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1807 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1808 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1809 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1810 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1811 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1812 Read extra field from the current file (opened by unzOpenCurrentFile) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1813 This is the local-header version of the extra field (sometimes, there is |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1814 more info in the local-header version than in the central-header) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1815 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1816 if buf==NULL, it return the size of the local extra field that can be read |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1817 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1818 if buf!=NULL, len is the size of the buffer, the extra header is copied in |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1819 buf. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1820 the return value is the number of bytes copied in buf, or (if <0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1821 the error code |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1822 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1823 extern int ZEXPORT unzGetLocalExtrafield(unzFile file, voidp buf, unsigned len) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1824 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1825 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1826 uInt read_now; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1827 ZPOS64_T size_to_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1828 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1829 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1830 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1831 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1832 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1833 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1834 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1835 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1836 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1837 size_to_read = (pfile_in_zip_read_info->size_local_extrafield - |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1838 pfile_in_zip_read_info->pos_local_extrafield); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1839 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1840 if (buf==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1841 return (int)size_to_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1842 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1843 if (len>size_to_read) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1844 read_now = (uInt)size_to_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1845 else |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1846 read_now = (uInt)len ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1847 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1848 if (read_now==0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1849 return 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1850 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1851 if (ZSEEK64(pfile_in_zip_read_info->z_filefunc, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1852 pfile_in_zip_read_info->filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1853 pfile_in_zip_read_info->offset_local_extrafield + |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1854 pfile_in_zip_read_info->pos_local_extrafield, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1855 ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1856 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1857 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1858 if (ZREAD64(pfile_in_zip_read_info->z_filefunc, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1859 pfile_in_zip_read_info->filestream, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1860 buf,read_now)!=read_now) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1861 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1862 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1863 return (int)read_now; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1864 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1865 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1866 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1867 Close the file in zip opened with unzOpenCurrentFile |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1868 Return UNZ_CRCERROR if all the file was read but the CRC is not good |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1869 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1870 extern int ZEXPORT unzCloseCurrentFile(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1871 int err=UNZ_OK; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1872 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1873 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1874 file_in_zip64_read_info_s* pfile_in_zip_read_info; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1875 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1876 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1877 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1878 pfile_in_zip_read_info=s->pfile_in_zip_read; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1879 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1880 if (pfile_in_zip_read_info==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1881 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1882 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1883 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1884 if ((pfile_in_zip_read_info->rest_read_uncompressed == 0) && |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1885 (!pfile_in_zip_read_info->raw)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1886 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1887 if (pfile_in_zip_read_info->crc32 != pfile_in_zip_read_info->crc32_wait) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1888 err=UNZ_CRCERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1889 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1890 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1891 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1892 free(pfile_in_zip_read_info->read_buffer); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1893 pfile_in_zip_read_info->read_buffer = NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1894 if (pfile_in_zip_read_info->stream_initialised == Z_DEFLATED) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1895 inflateEnd(&pfile_in_zip_read_info->stream); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1896 #ifdef HAVE_BZIP2 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1897 else if (pfile_in_zip_read_info->stream_initialised == Z_BZIP2ED) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1898 BZ2_bzDecompressEnd(&pfile_in_zip_read_info->bstream); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1899 #endif |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1900 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1901 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1902 pfile_in_zip_read_info->stream_initialised = 0; |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1903 free(pfile_in_zip_read_info); |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1904 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1905 s->pfile_in_zip_read=NULL; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1906 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1907 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1908 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1909 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1910 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1911 /* |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1912 Get the global comment string of the ZipFile, in the szComment buffer. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1913 uSizeBuf is the size of the szComment buffer. |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1914 return the number of byte copied or an error code <0 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1915 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1916 extern int ZEXPORT unzGetGlobalComment(unzFile file, char * szComment, uLong uSizeBuf) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1917 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1918 uLong uReadThis ; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1919 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1920 return (int)UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1921 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1922 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1923 uReadThis = uSizeBuf; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1924 if (uReadThis>s->gi.size_comment) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1925 uReadThis = s->gi.size_comment; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1926 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1927 if (ZSEEK64(s->z_filefunc,s->filestream,s->central_pos+22,ZLIB_FILEFUNC_SEEK_SET)!=0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1928 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1929 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1930 if (uReadThis>0) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1931 { |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1932 *szComment='\0'; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1933 if (ZREAD64(s->z_filefunc,s->filestream,szComment,uReadThis)!=uReadThis) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1934 return UNZ_ERRNO; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1935 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1936 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1937 if ((szComment != NULL) && (uSizeBuf > s->gi.size_comment)) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1938 *(szComment+s->gi.size_comment)='\0'; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1939 return (int)uReadThis; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1940 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1941 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1942 /* Additions by RX '2004 */ |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1943 extern ZPOS64_T ZEXPORT unzGetOffset64(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1944 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1945 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1946 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1947 return 0; //UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1948 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1949 if (!s->current_file_ok) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1950 return 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1951 if (s->gi.number_entry != 0 && s->gi.number_entry != 0xffff) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1952 if (s->num_file==s->gi.number_entry) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1953 return 0; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1954 return s->pos_in_central_dir; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1955 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1956 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1957 extern uLong ZEXPORT unzGetOffset(unzFile file) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1958 ZPOS64_T offset64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1959 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1960 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1961 return 0; //UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1962 offset64 = unzGetOffset64(file); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1963 return (uLong)offset64; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1964 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1965 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1966 extern int ZEXPORT unzSetOffset64(unzFile file, ZPOS64_T pos) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1967 unz64_s* s; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1968 int err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1969 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1970 if (file==NULL) |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1971 return UNZ_PARAMERROR; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1972 s=(unz64_s*)file; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1973 |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1974 s->pos_in_central_dir = pos; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1975 s->num_file = s->gi.number_entry; /* hack */ |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1976 err = unz64local_GetCurrentFileInfoInternal(file,&s->cur_file_info, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1977 &s->cur_file_info_internal, |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1978 NULL,0,NULL,0,NULL,0); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1979 s->current_file_ok = (err == UNZ_OK); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1980 return err; |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1981 } |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1982 |
5428
8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
Alain Mazy <am@osimis.io>
parents:
4354
diff
changeset
|
1983 extern int ZEXPORT unzSetOffset (unzFile file, uLong pos) { |
4354
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1984 return unzSetOffset64(file,pos); |
bcfb53d1bc56
trying to uncompress one zip archive
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff
changeset
|
1985 } |