Skip to content

Commit 0d57c06

Browse files
committed
update bundled libzip to 1.1.2
1 parent 78b2931 commit 0d57c06

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+752
-246
lines changed

NEWS

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ PHP NEWS
8181

8282
- Zip:
8383
. Fixed bug #71561 (NULL pointer dereference in Zip::ExtractTo). (Laruence)
84+
. Update bundled libzip to 1.1.2. (Remi, Anatol)
8485

8586
04 Feb 2016 PHP 7.0.3
8687

ext/zip/config.m4

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ if test "$PHP_ZIP" != "no"; then
122122
lib/zip_get_archive_comment.c lib/zip_get_archive_flag.c lib/zip_get_compression_implementation.c\
123123
lib/zip_get_encryption_implementation.c lib/zip_get_file_comment.c lib/zip_get_name.c lib/zip_get_num_entries.c \
124124
lib/zip_get_num_files.c lib/zip_memdup.c lib/zip_name_locate.c lib/zip_new.c lib/zip_open.c lib/zip_rename.c lib/zip_replace.c\
125+
lib/zip_hash.c \
125126
lib/zip_set_archive_comment.c lib/zip_set_archive_flag.c lib/zip_set_default_password.c lib/zip_set_file_comment.c\
126127
lib/zip_set_file_compression.c lib/zip_set_name.c lib/zip_source_buffer.c lib/zip_source_close.c lib/zip_source_crc.c\
127128
lib/zip_source_deflate.c lib/zip_source_error.c lib/zip_source_file.c lib/zip_source_filep.c lib/zip_source_free.c\

ext/zip/config.w32

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ if (PHP_ZIP != "no") {
2121
zip_get_archive_comment.c zip_get_archive_flag.c zip_get_compression_implementation.c\
2222
zip_get_encryption_implementation.c zip_get_file_comment.c zip_get_name.c zip_get_num_entries.c \
2323
zip_get_num_files.c zip_memdup.c zip_name_locate.c zip_new.c zip_open.c zip_rename.c zip_replace.c\
24+
zip_hash.c \
2425
zip_set_archive_comment.c zip_set_archive_flag.c zip_set_default_password.c zip_set_file_comment.c\
2526
zip_set_file_compression.c zip_set_name.c zip_source_buffer.c zip_source_close.c zip_source_crc.c\
2627
zip_source_deflate.c zip_source_error.c zip_source_filep.c zip_source_free.c\

ext/zip/lib/zip_add_entry.c

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
zip_add_entry.c -- create and init struct zip_entry
3-
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
3+
Copyright (C) 1999-2015 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 <[email protected]>
@@ -46,8 +46,19 @@ _zip_add_entry(zip_t *za)
4646

4747
if (za->nentry+1 >= za->nentry_alloc) {
4848
zip_entry_t *rentries;
49-
zip_uint64_t nalloc = za->nentry_alloc + 16;
50-
zip_uint64_t realloc_size = sizeof(struct zip_entry) * (size_t)nalloc;
49+
zip_uint64_t nalloc = za->nentry_alloc;
50+
zip_uint64_t additional_entries = 2 * nalloc;
51+
zip_uint64_t realloc_size;
52+
53+
if (additional_entries < 16) {
54+
additional_entries = 16;
55+
}
56+
else if (additional_entries > 1024) {
57+
additional_entries = 1024;
58+
}
59+
/* neither + nor * overflows can happen: nentry_alloc * sizeof(struct zip_entry) < UINT64_MAX */
60+
nalloc += additional_entries;
61+
realloc_size = sizeof(struct zip_entry) * (size_t)nalloc;
5162

5263
if (sizeof(struct zip_entry) * (size_t)za->nentry_alloc > realloc_size) {
5364
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);

ext/zip/lib/zip_buffer.c

+11
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,17 @@ _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset)
303303
}
304304

305305

306+
int
307+
_zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length) {
308+
zip_uint64_t offset = buffer->offset + length;
309+
310+
if (offset < buffer->offset) {
311+
buffer->ok = false;
312+
return -1;
313+
}
314+
return _zip_buffer_set_offset(buffer, offset);
315+
}
316+
306317
zip_uint64_t
307318
_zip_buffer_size(zip_buffer_t *buffer)
308319
{

ext/zip/lib/zip_close.c

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
#ifdef HAVE_STRINGS_H
4141
#include <strings.h>
4242
#endif
43-
#include <errno.h>
4443
#ifdef HAVE_UNISTD_H
4544
#include <unistd.h>
4645
#endif

ext/zip/lib/zip_delete.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
zip_delete.c -- delete file from zip archive
3-
Copyright (C) 1999-2014 Dieter Baron and Thomas Klausner
3+
Copyright (C) 1999-2015 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 <[email protected]>
@@ -38,6 +38,8 @@
3838
ZIP_EXTERN int
3939
zip_delete(zip_t *za, zip_uint64_t idx)
4040
{
41+
const char *name;
42+
4143
if (idx >= za->nentry) {
4244
zip_error_set(&za->error, ZIP_ER_INVAL, 0);
4345
return -1;
@@ -48,6 +50,14 @@ zip_delete(zip_t *za, zip_uint64_t idx)
4850
return -1;
4951
}
5052

53+
if ((name=_zip_get_name(za, idx, 0, &za->error)) == NULL) {
54+
return -1;
55+
}
56+
57+
if (!_zip_hash_delete(za->names, (const zip_uint8_t *)name, &za->error)) {
58+
return -1;
59+
}
60+
5161
/* allow duplicate file names, because the file will
5262
* be removed directly afterwards */
5363
if (_zip_unchange(za, idx, 1) != 0)

0 commit comments

Comments
 (0)