Skip to content

Commit 0a950a0

Browse files
committedDec 30, 2013
Sync with pecl/zip 1.12.4dev
- update bunled libzip to 0.11.2 - expose zip_file_set_external_attributes + zip_file_get_external_attributes with new methods: ZipArchive::setExternalAttributesName ZipArchive::setExternalAttributesIndex ZipArchive::getExternalAttributesName ZipArchive::getExternalAttributesIndex
1 parent 5a756af commit 0a950a0

31 files changed

+400
-111
lines changed
 

‎ext/zip/config.m4

+10-3
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,14 @@ if test "$PHP_ZIP" != "no"; then
6363
AC_MSG_RESULT(from option: found in $PHP_LIBZIP)
6464

6565
elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzip; then
66-
LIBZIP_CFLAGS=`$PKG_CONFIG libzip --cflags`
67-
LIBZIP_LIBDIR=`$PKG_CONFIG libzip --variable=libdir`
68-
AC_MSG_RESULT(from pkgconfig: found in $LIBZIP_LIBDIR)
66+
if $PKG_CONFIG libzip --atleast-version 0.11; then
67+
LIBZIP_CFLAGS=`$PKG_CONFIG libzip --cflags`
68+
LIBZIP_LIBDIR=`$PKG_CONFIG libzip --variable=libdir`
69+
LIBZIP_VERSON=`$PKG_CONFIG libzip --modversion`
70+
AC_MSG_RESULT(from pkgconfig: version $LIBZIP_VERSON found in $LIBZIP_LIBDIR)
71+
else
72+
AC_MSG_ERROR(system libzip must be upgraded to version >= 0.11)
73+
fi
6974

7075
else
7176
for i in /usr/local /usr; do
@@ -107,6 +112,7 @@ if test "$PHP_ZIP" != "no"; then
107112
lib/zip_fclose.c lib/zip_fdopen.c lib/zip_file_add.c lib/zip_file_error_clear.c lib/zip_file_error_get.c\
108113
lib/zip_file_get_comment.c lib/zip_file_get_offset.c lib/zip_file_rename.c lib/zip_file_replace.c\
109114
lib/zip_file_set_comment.c lib/zip_file_strerror.c lib/zip_filerange_crc.c lib/zip_fopen.c\
115+
lib/zip_file_get_external_attributes.c lib/zip_file_set_external_attributes.c \
110116
lib/zip_fopen_encrypted.c lib/zip_fopen_index.c lib/zip_fopen_index_encrypted.c lib/zip_fread.c\
111117
lib/zip_get_archive_comment.c lib/zip_get_archive_flag.c lib/zip_get_compression_implementation.c\
112118
lib/zip_get_encryption_implementation.c lib/zip_get_file_comment.c lib/zip_get_name.c lib/zip_get_num_entries.c \
@@ -122,6 +128,7 @@ if test "$PHP_ZIP" != "no"; then
122128
AC_DEFINE(HAVE_ZIP,1,[ ])
123129
PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
124130
PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
131+
PHP_ADD_INCLUDE([$ext_srcdir/lib])
125132
PHP_SUBST(ZIP_SHARED_LIBADD)
126133
fi
127134

‎ext/zip/config.w32

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ ARG_ENABLE("zip", "ZIP support", "yes");
55

66
if (PHP_ZIP != "no") {
77
if (CHECK_HEADER_ADD_INCLUDE("zlib.h", "CFLAGS_ZIP", "..\\zlib;" + PHP_ZIP) &&
8+
CHECK_HEADER_ADD_INCLUDE("zipconf.h", "CFLAGS_ZIP", configure_module_dirname + "\\lib;" + PHP_ZIP) &&
89
(((PHP_ZLIB=="no") && (CHECK_LIB("zlib_a.lib", "zip", PHP_ZIP) || CHECK_LIB("zlib.lib", "zip", PHP_ZIP))) ||
910
(PHP_ZLIB_SHARED && CHECK_LIB("zlib.lib", "zip", PHP_ZIP)) || (PHP_ZLIB == "yes" && (!PHP_ZLIB_SHARED)))
1011
) {
@@ -26,7 +27,8 @@ if (PHP_ZIP != "no") {
2627
zip_source_function.c zip_source_layered.c zip_source_open.c zip_source_pkware.c zip_source_pop.c\
2728
zip_source_read.c zip_source_stat.c zip_source_window.c zip_source_zip.c zip_source_zip_new.c\
2829
zip_stat.c zip_stat_index.c zip_stat_init.c zip_strerror.c zip_string.c zip_unchange.c zip_unchange_all.c\
29-
zip_unchange_archive.c zip_unchange_data.c zip_utf-8.c mkstemp.c", "zip");
30+
zip_unchange_archive.c zip_unchange_data.c zip_utf-8.c mkstemp.c \
31+
zip_file_set_external_attributes.c zip_file_get_external_attributes.c", "zip");
3032

3133
AC_DEFINE('HAVE_ZIP', 1);
3234
ADD_FLAG("CFLAGS_ZIP", "/D _WIN32");

‎ext/zip/lib/config.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,9 @@
2121

2222
#else
2323
/* Building in PHP tree */
24-
#include "php_config.h"
24+
# ifdef _WIN32
25+
# include "config.w32.h"
26+
# else
27+
# include "php_config.h"
28+
# endif
2529
#endif

‎ext/zip/lib/php_zip_config.w32.h

+3
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,7 @@ typedef long long ssize_t;
5454
# endif
5555
#endif
5656

57+
# undef strcasecmp
58+
# define strcasecmp _strcmpi
59+
5760
#endif /* HAD_CONFIG_H */

‎ext/zip/lib/zip.h

+50-30
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
3. The names of the authors may not be used to endorse or promote
2121
products derived from this software without specific prior
2222
written permission.
23-
23+
2424
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
2525
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2626
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -35,8 +35,9 @@
3535
*/
3636

3737

38-
#include "main/php.h"
3938

39+
#include "main/php.h"
40+
4041
#ifdef PHP_WIN32
4142
#ifdef PHP_ZIP_EXPORTS
4243
# define ZIP_EXTERN __declspec(dllexport) _stdcall
@@ -48,23 +49,14 @@
4849
#else
4950
# define ZIP_EXTERN
5051
#endif
52+
5153

5254

53-
#ifndef ZIP_EXTERN
54-
#ifdef _WIN32
55-
#define ZIP_EXTERN __declspec(dllimport)
56-
#elif defined(__GNUC__) && __GNUC__ >= 4
57-
#define ZIP_EXTERN __attribute__ ((visibility ("default")))
58-
#else
59-
#define ZIP_EXTERN
55+
#ifdef __cplusplus
56+
extern "C" {
6057
#endif
61-
#endif
62-
63-
6458

65-
BEGIN_EXTERN_C()
66-
67-
#include "zipconf.h"
59+
#include <zipconf.h>
6860

6961
#include <sys/types.h>
7062
#include <stdio.h>
@@ -77,6 +69,7 @@ BEGIN_EXTERN_C()
7769
#define ZIP_CHECKCONS 4
7870
#define ZIP_TRUNCATE 8
7971

72+
8073
/* flags for zip_name_locate, zip_fopen, zip_stat, ... */
8174

8275
#define ZIP_FL_NOCASE 1u /* ignore case on name lookup */
@@ -190,6 +183,29 @@ BEGIN_EXTERN_C()
190183
#endif
191184
#define ZIP_EM_UNKNOWN 0xffff /* unknown algorithm */
192185

186+
#define ZIP_OPSYS_DOS 0x00u
187+
#define ZIP_OPSYS_AMIGA 0x01u
188+
#define ZIP_OPSYS_OPENVMS 0x02u
189+
#define ZIP_OPSYS_UNIX 0x03u
190+
#define ZIP_OPSYS_VM_CMS 0x04u
191+
#define ZIP_OPSYS_ATARI_ST 0x05u
192+
#define ZIP_OPSYS_OS_2 0x06u
193+
#define ZIP_OPSYS_MACINTOSH 0x07u
194+
#define ZIP_OPSYS_Z_SYSTEM 0x08u
195+
#define ZIP_OPSYS_CPM 0x09u
196+
#define ZIP_OPSYS_WINDOWS_NTFS 0x0au
197+
#define ZIP_OPSYS_MVS 0x0bu
198+
#define ZIP_OPSYS_VSE 0x0cu
199+
#define ZIP_OPSYS_ACORN_RISC 0x0du
200+
#define ZIP_OPSYS_VFAT 0x0eu
201+
#define ZIP_OPSYS_ALTERNATE_MVS 0x0fu
202+
#define ZIP_OPSYS_BEOS 0x10u
203+
#define ZIP_OPSYS_TANDEM 0x11u
204+
#define ZIP_OPSYS_OS_400 0x12u
205+
#define ZIP_OPSYS_OS_X 0x13u
206+
207+
#define ZIP_OPSYS_DEFAULT ZIP_OPSYS_UNIX
208+
193209

194210

195211
enum zip_source_cmd {
@@ -248,21 +264,32 @@ ZIP_EXTERN int zip_set_file_comment(struct zip *, zip_uint64_t, const char *, in
248264
#endif
249265

250266
ZIP_EXTERN int zip_archive_set_tempdir(struct zip *, const char *);
251-
ZIP_EXTERN zip_int64_t zip_file_add(struct zip *, const char *, struct zip_source *, zip_flags_t);
252-
ZIP_EXTERN zip_int64_t zip_dir_add(struct zip *, const char *, zip_flags_t);
253267
ZIP_EXTERN int zip_close(struct zip *);
254-
ZIP_EXTERN void zip_discard(struct zip *);
255268
ZIP_EXTERN int zip_delete(struct zip *, zip_uint64_t);
256-
ZIP_EXTERN int zip_file_extra_field_delete(struct zip *, zip_uint64_t, zip_uint16_t, zip_flags_t);
257-
ZIP_EXTERN int zip_file_extra_field_delete_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t);
269+
ZIP_EXTERN zip_int64_t zip_dir_add(struct zip *, const char *, zip_flags_t);
270+
ZIP_EXTERN void zip_discard(struct zip *);
258271
ZIP_EXTERN void zip_error_clear(struct zip *);
259272
ZIP_EXTERN void zip_error_get(struct zip *, int *, int *);
260273
ZIP_EXTERN int zip_error_get_sys_type(int);
261274
ZIP_EXTERN int zip_error_to_str(char *, zip_uint64_t, int, int);
262275
ZIP_EXTERN int zip_fclose(struct zip_file *);
263276
ZIP_EXTERN struct zip *zip_fdopen(int, int, int *);
277+
ZIP_EXTERN zip_int64_t zip_file_add(struct zip *, const char *, struct zip_source *, zip_flags_t);
264278
ZIP_EXTERN void zip_file_error_clear(struct zip_file *);
265279
ZIP_EXTERN void zip_file_error_get(struct zip_file *, int *, int *);
280+
ZIP_EXTERN int zip_file_extra_field_delete(struct zip *, zip_uint64_t, zip_uint16_t, zip_flags_t);
281+
ZIP_EXTERN int zip_file_extra_field_delete_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_flags_t);
282+
ZIP_EXTERN int zip_file_extra_field_set(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_uint16_t, zip_flags_t);
283+
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(struct zip *, zip_uint64_t, zip_flags_t);
284+
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_flags_t);
285+
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t *, zip_uint16_t *, zip_flags_t);
286+
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *, zip_flags_t);
287+
ZIP_EXTERN const char *zip_file_get_comment(struct zip *, zip_uint64_t, zip_uint32_t *, zip_flags_t);
288+
ZIP_EXTERN int zip_file_get_external_attributes(struct zip *, zip_uint64_t, zip_flags_t, zip_uint8_t *, zip_uint32_t *);
289+
ZIP_EXTERN int zip_file_rename(struct zip *, zip_uint64_t, const char *, zip_flags_t);
290+
ZIP_EXTERN int zip_file_replace(struct zip *, zip_uint64_t, struct zip_source *, zip_flags_t);
291+
ZIP_EXTERN int zip_file_set_comment(struct zip *, zip_uint64_t, const char *, zip_uint16_t, zip_flags_t);
292+
ZIP_EXTERN int zip_file_set_external_attributes(struct zip *, zip_uint64_t, zip_flags_t, zip_uint8_t, zip_uint32_t);
266293
ZIP_EXTERN const char *zip_file_strerror(struct zip_file *);
267294
ZIP_EXTERN struct zip_file *zip_fopen(struct zip *, const char *, zip_flags_t);
268295
ZIP_EXTERN struct zip_file *zip_fopen_encrypted(struct zip *, const char *, zip_flags_t, const char *);
@@ -271,23 +298,14 @@ ZIP_EXTERN struct zip_file *zip_fopen_index_encrypted(struct zip *, zip_uint64_t
271298
ZIP_EXTERN zip_int64_t zip_fread(struct zip_file *, void *, zip_uint64_t);
272299
ZIP_EXTERN const char *zip_get_archive_comment(struct zip *, int *, zip_flags_t);
273300
ZIP_EXTERN int zip_get_archive_flag(struct zip *, zip_flags_t, zip_flags_t);
274-
ZIP_EXTERN const char *zip_file_get_comment(struct zip *, zip_uint64_t, zip_uint32_t *, zip_flags_t);
275-
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t *, zip_uint16_t *, zip_flags_t);
276-
ZIP_EXTERN const zip_uint8_t *zip_file_extra_field_get_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, zip_uint16_t *, zip_flags_t);
277-
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count(struct zip *, zip_uint64_t, zip_flags_t);
278-
ZIP_EXTERN zip_int16_t zip_file_extra_fields_count_by_id(struct zip *, zip_uint64_t, zip_uint16_t, zip_flags_t);
279301
ZIP_EXTERN const char *zip_get_name(struct zip *, zip_uint64_t, zip_flags_t);
280302
ZIP_EXTERN zip_int64_t zip_get_num_entries(struct zip *, zip_flags_t);
281303
ZIP_EXTERN zip_int64_t zip_name_locate(struct zip *, const char *, zip_flags_t);
282304
ZIP_EXTERN struct zip *zip_open(const char *, int, int *);
283-
ZIP_EXTERN int zip_file_rename(struct zip *, zip_uint64_t, const char *, zip_flags_t);
284-
ZIP_EXTERN int zip_file_replace(struct zip *, zip_uint64_t, struct zip_source *, zip_flags_t);
285305
ZIP_EXTERN int zip_set_archive_comment(struct zip *, const char *, zip_uint16_t);
286306
ZIP_EXTERN int zip_set_archive_flag(struct zip *, zip_flags_t, int);
287307
ZIP_EXTERN int zip_set_default_password(struct zip *, const char *);
288-
ZIP_EXTERN int zip_file_set_comment(struct zip *, zip_uint64_t, const char *, zip_uint16_t, zip_flags_t);
289308
ZIP_EXTERN int zip_set_file_compression(struct zip *, zip_uint64_t, zip_int32_t, zip_uint32_t);
290-
ZIP_EXTERN int zip_file_extra_field_set(struct zip *, zip_uint64_t, zip_uint16_t, zip_uint16_t, const zip_uint8_t *, zip_uint16_t, zip_flags_t);
291309
ZIP_EXTERN struct zip_source *zip_source_buffer(struct zip *, const void *, zip_uint64_t, int);
292310
ZIP_EXTERN struct zip_source *zip_source_file(struct zip *, const char *, zip_uint64_t, zip_int64_t);
293311
ZIP_EXTERN struct zip_source *zip_source_filep(struct zip *, FILE *, zip_uint64_t, zip_int64_t);
@@ -302,6 +320,8 @@ ZIP_EXTERN int zip_unchange(struct zip *, zip_uint64_t);
302320
ZIP_EXTERN int zip_unchange_all(struct zip *);
303321
ZIP_EXTERN int zip_unchange_archive(struct zip *);
304322

323+
#ifdef __cplusplus
324+
}
325+
#endif
305326

306-
END_EXTERN_C();
307327
#endif /* _HAD_ZIP_H */

‎ext/zip/lib/zip_add.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
3. The names of the authors may not be used to endorse or promote
1818
products derived from this software without specific prior
1919
written permission.
20-
20+
2121
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
2222
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2323
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

‎ext/zip/lib/zip_add_entry.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ _zip_add_entry(struct zip *za)
4949
if (za->nentry+1 >= za->nentry_alloc) {
5050
struct zip_entry *rentries;
5151
zip_uint64_t nalloc = za->nentry_alloc + 16;
52-
rentries = (struct zip_entry *)realloc(za->entry, sizeof(struct zip_entry) * nalloc);
52+
/* TODO check for overflow */
53+
rentries = (struct zip_entry *)realloc(za->entry, sizeof(struct zip_entry) * (size_t)nalloc);
5354
if (!rentries) {
5455
_zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
5556
return -1;

‎ext/zip/lib/zip_close.c

+18-17
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
zip_close.c -- close zip archive and update changes
3-
Copyright (C) 1999-2011 Dieter Baron and Thomas Klausner
3+
Copyright (C) 1999-2013 Dieter Baron and Thomas Klausner
44
55
This file is part of libzip, a library to manipulate ZIP archives.
66
The authors can be contacted at <libzip@nih.at>
@@ -17,7 +17,7 @@
1717
3. The names of the authors may not be used to endorse or promote
1818
products derived from this software without specific prior
1919
written permission.
20-
20+
2121
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
2222
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
2323
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -47,7 +47,7 @@
4747
#endif
4848
#include <sys/types.h>
4949
#include <sys/stat.h>
50-
#ifdef PHP_WIN32
50+
#ifdef _WIN32
5151
#include <io.h>
5252
#include <fcntl.h>
5353
#endif
@@ -73,7 +73,7 @@ zip_close(struct zip *za)
7373
int error;
7474
char *temp;
7575
FILE *out;
76-
#ifndef PHP_WIN32
76+
#ifndef _WIN32
7777
mode_t mask;
7878
#endif
7979
struct zip_filelist *filelist;
@@ -110,18 +110,18 @@ zip_close(struct zip *za)
110110
return -1;
111111
}
112112

113-
if ((filelist=(struct zip_filelist *)malloc(sizeof(filelist[0])*survivors)) == NULL)
113+
if ((filelist=(struct zip_filelist *)malloc(sizeof(filelist[0])*(size_t)survivors)) == NULL)
114114
return -1;
115115

116116
/* archive comment is special for torrentzip */
117117
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0)) {
118-
/* XXX: use internal function when zip_set_archive_comment clears TORRENT flag */
118+
/* TODO: use internal function when zip_set_archive_comment clears TORRENT flag */
119119
if (zip_set_archive_comment(za, TORRENT_SIG "XXXXXXXX", TORRENT_SIG_LEN + TORRENT_CRC_LEN) < 0) {
120120
free(filelist);
121121
return -1;
122122
}
123123
}
124-
/* XXX: if no longer torrentzip and archive comment not changed by user, delete it */
124+
/* TODO: if no longer torrentzip and archive comment not changed by user, delete it */
125125

126126

127127
/* create list of files with index into original archive */
@@ -153,7 +153,7 @@ zip_close(struct zip *za)
153153

154154

155155
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
156-
qsort(filelist, survivors, sizeof(filelist[0]),
156+
qsort(filelist, (size_t)survivors, sizeof(filelist[0]),
157157
_zip_torrentzip_cmp);
158158

159159
new_torrentzip = (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0) == 1
@@ -189,7 +189,7 @@ zip_close(struct zip *za)
189189
_zip_dirent_torrent_normalize(entry->changes);
190190

191191

192-
de->offset = (zip_uint64_t)ftello(out); /* XXX: check for errors */
192+
de->offset = (zip_uint64_t)ftello(out); /* TODO: check for errors */
193193

194194
if (new_data) {
195195
struct zip_source *zs;
@@ -225,7 +225,7 @@ zip_close(struct zip *za)
225225
error = 1;
226226
break;
227227
}
228-
if ((fseek(za->zp, (off_t)offset, SEEK_SET) < 0)) {
228+
if ((fseeko(za->zp, (off_t)offset, SEEK_SET) < 0)) {
229229
_zip_error_set(&za->error, ZIP_ER_SEEK, errno);
230230
error = 1;
231231
break;
@@ -273,7 +273,7 @@ zip_close(struct zip *za)
273273
}
274274
return -1;
275275
}
276-
#ifndef PHP_WIN32
276+
#ifndef _WIN32
277277
mask = umask(0);
278278
umask(mask);
279279
chmod(za->zn, 0666&~mask);
@@ -367,7 +367,7 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, FILE *ft
367367
return -1;
368368
}
369369

370-
/* XXX: deflate 0-byte files for torrentzip? */
370+
/* TODO: deflate 0-byte files for torrentzip? */
371371
if (de->comp_method != ZIP_CM_STORE && ((st.valid & ZIP_STAT_SIZE) == 0 || st.size != 0)) {
372372
if ((comp_impl=_zip_get_compression_implementation(de->comp_method)) == NULL) {
373373
_zip_error_set(&za->error, ZIP_ER_COMPNOTSUPP, 0);
@@ -398,7 +398,7 @@ add_data(struct zip *za, struct zip_source *src, struct zip_dirent *de, FILE *ft
398398

399399
while (s2 != src) {
400400
if ((s2=zip_source_pop(s2)) == NULL) {
401-
/* XXX: set erorr */
401+
/* TODO: set erorr */
402402
ret = -1;
403403
break;
404404
}
@@ -461,7 +461,7 @@ copy_data(FILE *fs, zip_uint64_t len, FILE *ft, struct zip_error *error)
461461
return 0;
462462

463463
while (len > 0) {
464-
nn = len > sizeof(buf) ? sizeof(buf) : len;
464+
nn = len > sizeof(buf) ? sizeof(buf) : len > SIZE_MAX ? SIZE_MAX : (size_t)len;
465465
if ((n=fread(buf, 1, nn, fs)) == 0) {
466466
if (ferror(fs)) {
467467
_zip_error_set(error, ZIP_ER_READ, errno);
@@ -477,7 +477,7 @@ copy_data(FILE *fs, zip_uint64_t len, FILE *ft, struct zip_error *error)
477477
_zip_error_set(error, ZIP_ER_WRITE, errno);
478478
return -1;
479479
}
480-
480+
481481
len -= n;
482482
}
483483

@@ -615,15 +615,16 @@ _zip_create_temp_output(struct zip *za, FILE **outp)
615615
free(temp);
616616
return NULL;
617617
}
618-
618+
619619
if ((tfp=fdopen(tfd, "r+b")) == NULL) {
620620
_zip_error_set(&za->error, ZIP_ER_TMPOPEN, errno);
621621
close(tfd);
622622
(void)remove(temp);
623623
free(temp);
624624
return NULL;
625625
}
626-
#ifdef PHP_WIN32
626+
627+
#ifdef _WIN32
627628
/*
628629
According to Pierre Joye, Windows in some environments per
629630
default creates text files, so force binary mode.

0 commit comments

Comments
 (0)
Please sign in to comment.