Mercurial > hg > orthanc
comparison OrthancFramework/Resources/ThirdParty/minizip/ioapi.h @ 5428:8174e45f48d8
Upgraded minizip library to stay away from CVE-2023-45853
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 17 Nov 2023 08:58:40 +0100 |
parents | d25f4c0fa160 |
children |
comparison
equal
deleted
inserted
replaced
5427:111e21b4f8bc | 5428:8174e45f48d8 |
---|---|
48 #if defined(USE_FILE32API) | 48 #if defined(USE_FILE32API) |
49 #define fopen64 fopen | 49 #define fopen64 fopen |
50 #define ftello64 ftell | 50 #define ftello64 ftell |
51 #define fseeko64 fseek | 51 #define fseeko64 fseek |
52 #else | 52 #else |
53 #ifdef __FreeBSD__ | 53 #if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64) |
54 #define fopen64 fopen | 54 #define fopen64 fopen |
55 #define ftello64 ftello | 55 #define ftello64 ftello |
56 #define fseeko64 fseeko | 56 #define fseeko64 fseeko |
57 #endif | 57 #endif |
58 #ifdef _MSC_VER | 58 #ifdef _MSC_VER |
80 | 80 |
81 #ifdef HAVE_MINIZIP64_CONF_H | 81 #ifdef HAVE_MINIZIP64_CONF_H |
82 #include "mz64conf.h" | 82 #include "mz64conf.h" |
83 #endif | 83 #endif |
84 | 84 |
85 /* a type choosen by DEFINE */ | 85 /* a type chosen by DEFINE */ |
86 #ifdef HAVE_64BIT_INT_CUSTOM | 86 #ifdef HAVE_64BIT_INT_CUSTOM |
87 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; | 87 typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; |
88 #else | 88 #else |
89 #ifdef HAS_STDINT_H | 89 #ifdef HAS_STDINT_H |
90 #include "stdint.h" | 90 #include "stdint.h" |
91 typedef uint64_t ZPOS64_T; | 91 typedef uint64_t ZPOS64_T; |
92 #else | 92 #else |
93 | 93 |
94 /* Maximum unsigned 32-bit value used as placeholder for zip64 */ | 94 |
95 #define MAXU32 0xffffffff | |
96 | 95 |
97 #if defined(_MSC_VER) || defined(__BORLANDC__) | 96 #if defined(_MSC_VER) || defined(__BORLANDC__) |
98 typedef unsigned __int64 ZPOS64_T; | 97 typedef unsigned __int64 ZPOS64_T; |
99 #else | 98 #else |
100 typedef unsigned long long int ZPOS64_T; | 99 typedef unsigned long long int ZPOS64_T; |
101 #endif | 100 #endif |
102 #endif | 101 #endif |
103 #endif | 102 #endif |
104 | 103 |
105 | 104 /* Maximum unsigned 32-bit value used as placeholder for zip64 */ |
105 #ifndef MAXU32 | |
106 #define MAXU32 (0xffffffff) | |
107 #endif | |
106 | 108 |
107 #ifdef __cplusplus | 109 #ifdef __cplusplus |
108 extern "C" { | 110 extern "C" { |
109 #endif | 111 #endif |
110 | 112 |
130 #endif | 132 #endif |
131 | 133 |
132 | 134 |
133 | 135 |
134 | 136 |
135 typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, const char* filename, int mode)); | 137 typedef voidpf (ZCALLBACK *open_file_func) (voidpf opaque, const char* filename, int mode); |
136 typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); | 138 typedef uLong (ZCALLBACK *read_file_func) (voidpf opaque, voidpf stream, void* buf, uLong size); |
137 typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); | 139 typedef uLong (ZCALLBACK *write_file_func) (voidpf opaque, voidpf stream, const void* buf, uLong size); |
138 typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); | 140 typedef int (ZCALLBACK *close_file_func) (voidpf opaque, voidpf stream); |
139 typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); | 141 typedef int (ZCALLBACK *testerror_file_func) (voidpf opaque, voidpf stream); |
140 | 142 |
141 typedef long (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); | 143 typedef long (ZCALLBACK *tell_file_func) (voidpf opaque, voidpf stream); |
142 typedef long (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); | 144 typedef long (ZCALLBACK *seek_file_func) (voidpf opaque, voidpf stream, uLong offset, int origin); |
143 | 145 |
144 | 146 |
145 /* here is the "old" 32 bits structure structure */ | 147 /* here is the "old" 32 bits structure */ |
146 typedef struct zlib_filefunc_def_s | 148 typedef struct zlib_filefunc_def_s |
147 { | 149 { |
148 open_file_func zopen_file; | 150 open_file_func zopen_file; |
149 read_file_func zread_file; | 151 read_file_func zread_file; |
150 write_file_func zwrite_file; | 152 write_file_func zwrite_file; |
153 close_file_func zclose_file; | 155 close_file_func zclose_file; |
154 testerror_file_func zerror_file; | 156 testerror_file_func zerror_file; |
155 voidpf opaque; | 157 voidpf opaque; |
156 } zlib_filefunc_def; | 158 } zlib_filefunc_def; |
157 | 159 |
158 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); | 160 typedef ZPOS64_T (ZCALLBACK *tell64_file_func) (voidpf opaque, voidpf stream); |
159 typedef long (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); | 161 typedef long (ZCALLBACK *seek64_file_func) (voidpf opaque, voidpf stream, ZPOS64_T offset, int origin); |
160 typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, const void* filename, int mode)); | 162 typedef voidpf (ZCALLBACK *open64_file_func) (voidpf opaque, const void* filename, int mode); |
161 | 163 |
162 typedef struct zlib_filefunc64_def_s | 164 typedef struct zlib_filefunc64_def_s |
163 { | 165 { |
164 open64_file_func zopen64_file; | 166 open64_file_func zopen64_file; |
165 read_file_func zread_file; | 167 read_file_func zread_file; |
169 close_file_func zclose_file; | 171 close_file_func zclose_file; |
170 testerror_file_func zerror_file; | 172 testerror_file_func zerror_file; |
171 voidpf opaque; | 173 voidpf opaque; |
172 } zlib_filefunc64_def; | 174 } zlib_filefunc64_def; |
173 | 175 |
174 void fill_fopen64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); | 176 void fill_fopen64_filefunc(zlib_filefunc64_def* pzlib_filefunc_def); |
175 void fill_fopen_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); | 177 void fill_fopen_filefunc(zlib_filefunc_def* pzlib_filefunc_def); |
176 | 178 |
177 /* now internal definition, only for zip.c and unzip.h */ | 179 /* now internal definition, only for zip.c and unzip.h */ |
178 typedef struct zlib_filefunc64_32_def_s | 180 typedef struct zlib_filefunc64_32_def_s |
179 { | 181 { |
180 zlib_filefunc64_def zfile_func64; | 182 zlib_filefunc64_def zfile_func64; |
189 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) | 191 //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) |
190 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) | 192 //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) |
191 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) | 193 #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) |
192 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) | 194 #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) |
193 | 195 |
194 voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode)); | 196 voidpf call_zopen64(const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode); |
195 long call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); | 197 long call_zseek64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin); |
196 ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); | 198 ZPOS64_T call_ztell64(const zlib_filefunc64_32_def* pfilefunc,voidpf filestream); |
197 | 199 |
198 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); | 200 void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); |
199 | 201 |
200 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) | 202 #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) |
201 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) | 203 #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) |
202 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) | 204 #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) |
203 | 205 |