|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/config.m4.systzip php-5.5.2RC1/ext/zip/config.m4
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/config.m4.systzip 2013-07-31 10:41:15.000000000 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/config.m4 2013-08-08 09:24:07.577567241 +0200
|
|
|
37fd76 |
@@ -13,65 +13,116 @@ fi
|
|
|
37fd76 |
PHP_ARG_WITH(pcre-dir, pcre install prefix,
|
|
|
37fd76 |
[ --with-pcre-dir ZIP: pcre install prefix], no, no)
|
|
|
37fd76 |
|
|
|
37fd76 |
+PHP_ARG_WITH(libzip, libzip,
|
|
|
37fd76 |
+[ --with-libzip[=DIR] ZIP: use libzip], no, no)
|
|
|
37fd76 |
+
|
|
|
37fd76 |
if test "$PHP_ZIP" != "no"; then
|
|
|
37fd76 |
+ if test "$PHP_LIBZIP" != "no"; then
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ dnl system libzip, depends on libzip
|
|
|
37fd76 |
+ AC_MSG_CHECKING(for libzip)
|
|
|
37fd76 |
+ if test -r $PHP_LIBZIP/include/zip.h; then
|
|
|
37fd76 |
+ LIBZIP_CFLAGS="-I$PHP_LIBZIP/include"
|
|
|
37fd76 |
+ LIBZIP_LIBDIR="$PHP_LIBZIP/$PHP_LIBDIR"
|
|
|
37fd76 |
+ AC_MSG_RESULT(from option: found in $PHP_LIBZIP)
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ elif test -x "$PKG_CONFIG" && $PKG_CONFIG --exists libzip; then
|
|
|
37fd76 |
+ LIBZIP_CFLAGS=`$PKG_CONFIG libzip --cflags`
|
|
|
37fd76 |
+ LIBZIP_LIBDIR=`$PKG_CONFIG libzip --variable=libdir`
|
|
|
37fd76 |
+ AC_MSG_RESULT(from pkgconfig: found in $LIBZIP_LIBDIR)
|
|
|
37fd76 |
|
|
|
37fd76 |
- if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
|
|
|
37fd76 |
- if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
|
|
|
37fd76 |
- PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
|
|
|
37fd76 |
- PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
|
|
|
37fd76 |
- elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
|
|
|
37fd76 |
- PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
|
|
|
37fd76 |
- PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
|
|
|
37fd76 |
else
|
|
|
37fd76 |
- AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"])
|
|
|
37fd76 |
+ for i in /usr/local /usr; do
|
|
|
37fd76 |
+ if test -r $i/include/zip.h; then
|
|
|
37fd76 |
+ LIBZIP_CFLAGS="-I$i/include"
|
|
|
37fd76 |
+ LIBZIP_LIBDIR="$i/$PHP_LIBDIR"
|
|
|
37fd76 |
+ AC_MSG_RESULT(in default path: found in $i)
|
|
|
37fd76 |
+ break
|
|
|
37fd76 |
+ fi
|
|
|
37fd76 |
+ done
|
|
|
37fd76 |
fi
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ if test -z "$LIBZIP_LIBDIR"; then
|
|
|
37fd76 |
+ AC_MSG_RESULT(not found)
|
|
|
37fd76 |
+ AC_MSG_ERROR(Please reinstall the libzip distribution)
|
|
|
37fd76 |
+ fi
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ dnl Could not think of a simple way to check libzip for overwrite support
|
|
|
37fd76 |
+ PHP_CHECK_LIBRARY(zip, zip_open,
|
|
|
37fd76 |
+ [
|
|
|
37fd76 |
+ PHP_ADD_LIBRARY_WITH_PATH(zip, $LIBZIP_LIBDIR, ZIP_SHARED_LIBADD)
|
|
|
37fd76 |
+ AC_DEFINE(HAVE_LIBZIP,1,[ ])
|
|
|
37fd76 |
+ ], [
|
|
|
37fd76 |
+ AC_MSG_ERROR(could not find usable libzip)
|
|
|
37fd76 |
+ ], [
|
|
|
37fd76 |
+ -L$LIBZIP_LIBDIR
|
|
|
37fd76 |
+ ])
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ AC_DEFINE(HAVE_ZIP,1,[ ])
|
|
|
37fd76 |
+ PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c, $ext_shared,, $LIBZIP_CFLAGS)
|
|
|
37fd76 |
+ PHP_SUBST(ZIP_SHARED_LIBADD)
|
|
|
37fd76 |
else
|
|
|
37fd76 |
- for i in /usr/local /usr; do
|
|
|
37fd76 |
- if test -f "$i/include/zlib/zlib.h"; then
|
|
|
37fd76 |
- PHP_ZLIB_DIR="$i"
|
|
|
37fd76 |
- PHP_ZLIB_INCDIR="$i/include/zlib"
|
|
|
37fd76 |
- elif test -f "$i/include/zlib.h"; then
|
|
|
37fd76 |
- PHP_ZLIB_DIR="$i"
|
|
|
37fd76 |
- PHP_ZLIB_INCDIR="$i/include"
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ dnl bundled libzip, depends on zlib
|
|
|
37fd76 |
+ if test "$PHP_ZLIB_DIR" != "no" && test "$PHP_ZLIB_DIR" != "yes"; then
|
|
|
37fd76 |
+ if test -f "$PHP_ZLIB_DIR/include/zlib/zlib.h"; then
|
|
|
37fd76 |
+ PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
|
|
|
37fd76 |
+ PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include/zlib"
|
|
|
37fd76 |
+ elif test -f "$PHP_ZLIB_DIR/include/zlib.h"; then
|
|
|
37fd76 |
+ PHP_ZLIB_DIR="$PHP_ZLIB_DIR"
|
|
|
37fd76 |
+ PHP_ZLIB_INCDIR="$PHP_ZLIB_DIR/include"
|
|
|
37fd76 |
+ else
|
|
|
37fd76 |
+ AC_MSG_ERROR([Can not find zlib headers under "$PHP_ZLIB_DIR"])
|
|
|
37fd76 |
fi
|
|
|
37fd76 |
- done
|
|
|
37fd76 |
- fi
|
|
|
37fd76 |
+ else
|
|
|
37fd76 |
+ for i in /usr/local /usr; do
|
|
|
37fd76 |
+ if test -f "$i/include/zlib/zlib.h"; then
|
|
|
37fd76 |
+ PHP_ZLIB_DIR="$i"
|
|
|
37fd76 |
+ PHP_ZLIB_INCDIR="$i/include/zlib"
|
|
|
37fd76 |
+ elif test -f "$i/include/zlib.h"; then
|
|
|
37fd76 |
+ PHP_ZLIB_DIR="$i"
|
|
|
37fd76 |
+ PHP_ZLIB_INCDIR="$i/include"
|
|
|
37fd76 |
+ fi
|
|
|
37fd76 |
+ done
|
|
|
37fd76 |
+ fi
|
|
|
37fd76 |
|
|
|
37fd76 |
- dnl # zlib
|
|
|
37fd76 |
- AC_MSG_CHECKING([for the location of zlib])
|
|
|
37fd76 |
- if test "$PHP_ZLIB_DIR" = "no"; then
|
|
|
37fd76 |
- AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
|
|
|
37fd76 |
- else
|
|
|
37fd76 |
- AC_MSG_RESULT([$PHP_ZLIB_DIR])
|
|
|
37fd76 |
- PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD)
|
|
|
37fd76 |
- PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
|
|
|
37fd76 |
- fi
|
|
|
37fd76 |
+ dnl # zlib
|
|
|
37fd76 |
+ AC_MSG_CHECKING([for the location of zlib])
|
|
|
37fd76 |
+ if test "$PHP_ZLIB_DIR" = "no"; then
|
|
|
37fd76 |
+ AC_MSG_ERROR([zip support requires ZLIB. Use --with-zlib-dir=<DIR> to specify prefix where ZLIB include and library are located])
|
|
|
37fd76 |
+ else
|
|
|
37fd76 |
+ AC_MSG_RESULT([$PHP_ZLIB_DIR])
|
|
|
37fd76 |
+ PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR/$PHP_LIBDIR, ZIP_SHARED_LIBADD)
|
|
|
37fd76 |
+ PHP_ADD_INCLUDE($PHP_ZLIB_INCDIR)
|
|
|
37fd76 |
+ fi
|
|
|
37fd76 |
|
|
|
37fd76 |
- dnl This is PECL build, check if bundled PCRE library is used
|
|
|
37fd76 |
- old_CPPFLAGS=$CPPFLAGS
|
|
|
37fd76 |
- CPPFLAGS=$INCLUDES
|
|
|
37fd76 |
- AC_EGREP_CPP(yes,[
|
|
|
37fd76 |
+ dnl This is PECL build, check if bundled PCRE library is used
|
|
|
37fd76 |
+ old_CPPFLAGS=$CPPFLAGS
|
|
|
37fd76 |
+ CPPFLAGS=$INCLUDES
|
|
|
37fd76 |
+ AC_EGREP_CPP(yes,[
|
|
|
37fd76 |
#include <main/php_config.h>
|
|
|
37fd76 |
#if defined(HAVE_BUNDLED_PCRE) && !defined(COMPILE_DL_PCRE)
|
|
|
37fd76 |
yes
|
|
|
37fd76 |
#endif
|
|
|
37fd76 |
- ],[
|
|
|
37fd76 |
- PHP_PCRE_REGEX=yes
|
|
|
37fd76 |
- ],[
|
|
|
37fd76 |
- AC_EGREP_CPP(yes,[
|
|
|
37fd76 |
+ ],[
|
|
|
37fd76 |
+ PHP_PCRE_REGEX=yes
|
|
|
37fd76 |
+ ],[
|
|
|
37fd76 |
+ AC_EGREP_CPP(yes,[
|
|
|
37fd76 |
#include <main/php_config.h>
|
|
|
37fd76 |
#if defined(HAVE_PCRE) && !defined(COMPILE_DL_PCRE)
|
|
|
37fd76 |
yes
|
|
|
37fd76 |
#endif
|
|
|
37fd76 |
- ],[
|
|
|
37fd76 |
- PHP_PCRE_REGEX=pecl
|
|
|
37fd76 |
- ],[
|
|
|
37fd76 |
- PHP_PCRE_REGEX=no
|
|
|
37fd76 |
+ ],[
|
|
|
37fd76 |
+ PHP_PCRE_REGEX=pecl
|
|
|
37fd76 |
+ ],[
|
|
|
37fd76 |
+ PHP_PCRE_REGEX=no
|
|
|
37fd76 |
+ ])
|
|
|
37fd76 |
])
|
|
|
37fd76 |
- ])
|
|
|
37fd76 |
- CPPFLAGS=$old_CPPFLAGS
|
|
|
37fd76 |
+ CPPFLAGS=$old_CPPFLAGS
|
|
|
37fd76 |
|
|
|
37fd76 |
- PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_error.c lib/zip_fclose.c \
|
|
|
37fd76 |
+ PHP_ZIP_SOURCES="$PHP_ZIP_SOURCES lib/zip_add.c lib/zip_error.c lib/zip_fclose.c \
|
|
|
37fd76 |
lib/zip_fread.c lib/zip_open.c lib/zip_source_filep.c \
|
|
|
37fd76 |
lib/zip_strerror.c lib/zip_close.c lib/zip_error_get.c \
|
|
|
37fd76 |
lib/zip_file_error_get.c lib/zip_free.c lib/zip_rename.c \
|
|
|
37fd76 |
@@ -98,10 +149,11 @@ yes
|
|
|
37fd76 |
lib/zip_source_open.c lib/zip_source_pkware.c lib/zip_source_pop.c \
|
|
|
37fd76 |
lib/zip_source_read.c lib/zip_source_stat.c"
|
|
|
37fd76 |
|
|
|
37fd76 |
- AC_DEFINE(HAVE_ZIP,1,[ ])
|
|
|
37fd76 |
- PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
|
|
|
37fd76 |
- PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
|
|
|
37fd76 |
- PHP_SUBST(ZIP_SHARED_LIBADD)
|
|
|
37fd76 |
+ AC_DEFINE(HAVE_ZIP,1,[ ])
|
|
|
37fd76 |
+ PHP_NEW_EXTENSION(zip, php_zip.c zip_stream.c $PHP_ZIP_SOURCES, $ext_shared)
|
|
|
37fd76 |
+ PHP_ADD_BUILD_DIR($ext_builddir/lib, 1)
|
|
|
37fd76 |
+ PHP_SUBST(ZIP_SHARED_LIBADD)
|
|
|
37fd76 |
+ fi
|
|
|
37fd76 |
|
|
|
37fd76 |
dnl so we always include the known-good working hack.
|
|
|
37fd76 |
PHP_ADD_MAKEFILE_FRAGMENT
|
|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/libzip-missing-0.10.h.systzip php-5.5.2RC1/ext/zip/libzip-missing-0.10.h
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/libzip-missing-0.10.h.systzip 2013-08-08 09:34:53.338910267 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/libzip-missing-0.10.h 2013-08-08 09:26:21.244072278 +0200
|
|
|
37fd76 |
@@ -0,0 +1,219 @@
|
|
|
37fd76 |
+/* Copied from libzip 0.10 */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* state of change of a file in zip archive */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+enum zip_state { ZIP_ST_UNCHANGED, ZIP_ST_DELETED, ZIP_ST_REPLACED,
|
|
|
37fd76 |
+ ZIP_ST_ADDED, ZIP_ST_RENAMED };
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* error source for layered sources */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+enum zip_les { ZIP_LES_NONE, ZIP_LES_UPPER, ZIP_LES_LOWER, ZIP_LES_INVAL };
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+typedef zip_int64_t (*zip_source_layered_callback)(struct zip_source *, void *,
|
|
|
37fd76 |
+ void *, zip_uint64_t,
|
|
|
37fd76 |
+ enum zip_source_cmd);
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip_error {
|
|
|
37fd76 |
+ int zip_err; /* libzip error code (ZIP_ER_*) */
|
|
|
37fd76 |
+ int sys_err; /* copy of errno (E*) or zlib error code */
|
|
|
37fd76 |
+ char *str; /* string representation or NULL */
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* zip archive, part of API */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip {
|
|
|
37fd76 |
+ char *zn; /* file name */
|
|
|
37fd76 |
+ FILE *zp; /* file */
|
|
|
37fd76 |
+ struct zip_error error; /* error information */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ unsigned int flags; /* archive global flags */
|
|
|
37fd76 |
+ unsigned int ch_flags; /* changed archive global flags */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ char *default_password; /* password used when no other supplied */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ struct zip_cdir *cdir; /* central directory */
|
|
|
37fd76 |
+ char *ch_comment; /* changed archive comment */
|
|
|
37fd76 |
+ int ch_comment_len; /* length of changed zip archive
|
|
|
37fd76 |
+ * comment, -1 if unchanged */
|
|
|
37fd76 |
+ zip_uint64_t nentry; /* number of entries */
|
|
|
37fd76 |
+ zip_uint64_t nentry_alloc; /* number of entries allocated */
|
|
|
37fd76 |
+ struct zip_entry *entry; /* entries */
|
|
|
37fd76 |
+ int nfile; /* number of opened files within archive */
|
|
|
37fd76 |
+ int nfile_alloc; /* number of files allocated */
|
|
|
37fd76 |
+ struct zip_file **file; /* opened files within archive */
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* file in zip archive, part of API */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip_file {
|
|
|
37fd76 |
+ struct zip *za; /* zip archive containing this file */
|
|
|
37fd76 |
+ struct zip_error error; /* error information */
|
|
|
37fd76 |
+ int eof;
|
|
|
37fd76 |
+ struct zip_source *src; /* data source */
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* zip archive directory entry (central or local) */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip_dirent {
|
|
|
37fd76 |
+ unsigned short version_madeby; /* (c) version of creator */
|
|
|
37fd76 |
+ unsigned short version_needed; /* (cl) version needed to extract */
|
|
|
37fd76 |
+ unsigned short bitflags; /* (cl) general purpose bit flag */
|
|
|
37fd76 |
+ unsigned short comp_method; /* (cl) compression method used */
|
|
|
37fd76 |
+ time_t last_mod; /* (cl) time of last modification */
|
|
|
37fd76 |
+ unsigned int crc; /* (cl) CRC-32 of uncompressed data */
|
|
|
37fd76 |
+ unsigned int comp_size; /* (cl) size of commpressed data */
|
|
|
37fd76 |
+ unsigned int uncomp_size; /* (cl) size of uncommpressed data */
|
|
|
37fd76 |
+ char *filename; /* (cl) file name (NUL-terminated) */
|
|
|
37fd76 |
+ unsigned short filename_len; /* (cl) length of filename (w/o NUL) */
|
|
|
37fd76 |
+ char *extrafield; /* (cl) extra field */
|
|
|
37fd76 |
+ unsigned short extrafield_len; /* (cl) length of extra field */
|
|
|
37fd76 |
+ char *comment; /* (c) file comment */
|
|
|
37fd76 |
+ unsigned short comment_len; /* (c) length of file comment */
|
|
|
37fd76 |
+ unsigned short disk_number; /* (c) disk number start */
|
|
|
37fd76 |
+ unsigned short int_attrib; /* (c) internal file attributes */
|
|
|
37fd76 |
+ unsigned int ext_attrib; /* (c) external file attributes */
|
|
|
37fd76 |
+ unsigned int offset; /* (c) offset of local header */
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* zip archive central directory */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip_cdir {
|
|
|
37fd76 |
+ struct zip_dirent *entry; /* directory entries */
|
|
|
37fd76 |
+ int nentry; /* number of entries */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ unsigned int size; /* size of central direcotry */
|
|
|
37fd76 |
+ unsigned int offset; /* offset of central directory in file */
|
|
|
37fd76 |
+ char *comment; /* zip archive comment */
|
|
|
37fd76 |
+ unsigned short comment_len; /* length of zip archive comment */
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip_source {
|
|
|
37fd76 |
+ struct zip_source *src;
|
|
|
37fd76 |
+ union {
|
|
|
37fd76 |
+ zip_source_callback f;
|
|
|
37fd76 |
+ zip_source_layered_callback l;
|
|
|
37fd76 |
+ } cb;
|
|
|
37fd76 |
+ void *ud;
|
|
|
37fd76 |
+ enum zip_les error_source;
|
|
|
37fd76 |
+ int is_open;
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+/* entry in zip archive directory */
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+struct zip_entry {
|
|
|
37fd76 |
+ enum zip_state state;
|
|
|
37fd76 |
+ struct zip_source *source;
|
|
|
37fd76 |
+ char *ch_filename;
|
|
|
37fd76 |
+ char *ch_extra;
|
|
|
37fd76 |
+ int ch_extra_len;
|
|
|
37fd76 |
+ char *ch_comment;
|
|
|
37fd76 |
+ int ch_comment_len;
|
|
|
37fd76 |
+};
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_dirent_finalize(struct zip_dirent *zde)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ free(zde->filename);
|
|
|
37fd76 |
+ zde->filename = NULL;
|
|
|
37fd76 |
+ free(zde->extrafield);
|
|
|
37fd76 |
+ zde->extrafield = NULL;
|
|
|
37fd76 |
+ free(zde->comment);
|
|
|
37fd76 |
+ zde->comment = NULL;
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_cdir_free(struct zip_cdir *cd)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ int i;
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ if (!cd)
|
|
|
37fd76 |
+ return;
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ for (i=0; i<cd->nentry; i++)
|
|
|
37fd76 |
+ _zip_dirent_finalize(cd->entry+i);
|
|
|
37fd76 |
+ free(cd->comment);
|
|
|
37fd76 |
+ free(cd->entry);
|
|
|
37fd76 |
+ free(cd);
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_error_fini(struct zip_error *err)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ free(err->str);
|
|
|
37fd76 |
+ err->str = NULL;
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_error_init(struct zip_error *err)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ err->zip_err = ZIP_ER_OK;
|
|
|
37fd76 |
+ err->sys_err = 0;
|
|
|
37fd76 |
+ err->str = NULL;
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_unchange_data(struct zip_entry *ze)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ if (ze->source) {
|
|
|
37fd76 |
+ zip_source_free(ze->source);
|
|
|
37fd76 |
+ ze->source = NULL;
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ ze->state = ze->ch_filename ? ZIP_ST_RENAMED : ZIP_ST_UNCHANGED;
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_entry_free(struct zip_entry *ze)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ free(ze->ch_filename);
|
|
|
37fd76 |
+ ze->ch_filename = NULL;
|
|
|
37fd76 |
+ free(ze->ch_extra);
|
|
|
37fd76 |
+ ze->ch_extra = NULL;
|
|
|
37fd76 |
+ ze->ch_extra_len = -1;
|
|
|
37fd76 |
+ free(ze->ch_comment);
|
|
|
37fd76 |
+ ze->ch_comment = NULL;
|
|
|
37fd76 |
+ ze->ch_comment_len = -1;
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ _zip_unchange_data(ze);
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void
|
|
|
37fd76 |
+_zip_error_set(struct zip_error *err, int ze, int se)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ if (err) {
|
|
|
37fd76 |
+ err->zip_err = ze;
|
|
|
37fd76 |
+ err->sys_err = se;
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+void _zip_free(struct zip *za)
|
|
|
37fd76 |
+{
|
|
|
37fd76 |
+ int i;
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ if (za == NULL)
|
|
|
37fd76 |
+ return;
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ if (za->zn)
|
|
|
37fd76 |
+ free(za->zn);
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ if (za->zp)
|
|
|
37fd76 |
+ fclose(za->zp);
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ free(za->default_password);
|
|
|
37fd76 |
+ _zip_cdir_free(za->cdir);
|
|
|
37fd76 |
+ free(za->ch_comment);
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ if (za->entry) {
|
|
|
37fd76 |
+ for (i=0; i<za->nentry; i++) {
|
|
|
37fd76 |
+ _zip_entry_free(za->entry+i);
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
+ free(za->entry);
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ for (i=0; i<za->nfile; i++) {
|
|
|
37fd76 |
+ if (za->file[i]->error.zip_err == ZIP_ER_OK) {
|
|
|
37fd76 |
+ _zip_error_set(&za->file[i]->error, ZIP_ER_ZIPCLOSED, 0);
|
|
|
37fd76 |
+ za->file[i]->za = NULL;
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+ free(za->file);
|
|
|
37fd76 |
+ free(za);
|
|
|
37fd76 |
+ return;
|
|
|
37fd76 |
+}
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+
|
|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/php_zip.c.systzip php-5.5.2RC1/ext/zip/php_zip.c
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/php_zip.c.systzip 2013-07-31 10:41:15.000000000 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/php_zip.c 2013-08-08 09:33:59.367735224 +0200
|
|
|
37fd76 |
@@ -30,8 +30,20 @@
|
|
|
37fd76 |
#include "ext/pcre/php_pcre.h"
|
|
|
37fd76 |
#include "ext/standard/php_filestat.h"
|
|
|
37fd76 |
#include "php_zip.h"
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+#if defined(HAVE_LIBZIP)
|
|
|
37fd76 |
+#include <zip.h>
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+#if LIBZIP_VERSION_MAJOR == 0 && LIBZIP_VERSION_MINOR == 10
|
|
|
37fd76 |
+#include "libzip-missing-0.10.h"
|
|
|
37fd76 |
+#else
|
|
|
37fd76 |
+#error "Only libzip 0.10 supported for now"
|
|
|
37fd76 |
+#endif
|
|
|
37fd76 |
+
|
|
|
37fd76 |
+#else
|
|
|
37fd76 |
#include "lib/zip.h"
|
|
|
37fd76 |
#include "lib/zipint.h"
|
|
|
37fd76 |
+#endif
|
|
|
37fd76 |
|
|
|
37fd76 |
/* zip_open is a macro for renaming libzip zipopen, so we need to use PHP_NAMED_FUNCTION */
|
|
|
37fd76 |
static PHP_NAMED_FUNCTION(zif_zip_open);
|
|
|
37fd76 |
@@ -1631,6 +1643,10 @@ static ZIPARCHIVE_METHOD(addEmptyDir)
|
|
|
37fd76 |
}
|
|
|
37fd76 |
|
|
|
37fd76 |
idx = zip_stat(intern, s, 0, &sb);
|
|
|
37fd76 |
+ /* We don't care about the NOENT status error here. */
|
|
|
37fd76 |
+ if (intern->error.zip_err == ZIP_ER_NOENT) {
|
|
|
37fd76 |
+ _zip_error_set(&intern->error, ZIP_ER_OK, 0);
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
if (idx >= 0) {
|
|
|
37fd76 |
RETVAL_FALSE;
|
|
|
37fd76 |
} else {
|
|
|
37fd76 |
@@ -1853,6 +1869,10 @@ static ZIPARCHIVE_METHOD(addFromString)
|
|
|
37fd76 |
}
|
|
|
37fd76 |
|
|
|
37fd76 |
cur_idx = zip_name_locate(intern, (const char *)name, 0);
|
|
|
37fd76 |
+ /* We don't care about the NOENT status error here. */
|
|
|
37fd76 |
+ if (intern->error.zip_err == ZIP_ER_NOENT) {
|
|
|
37fd76 |
+ _zip_error_set(&intern->error, ZIP_ER_OK, 0);
|
|
|
37fd76 |
+ }
|
|
|
37fd76 |
/* TODO: fix _zip_replace */
|
|
|
37fd76 |
if (cur_idx >= 0) {
|
|
|
37fd76 |
if (zip_delete(intern, cur_idx) == -1) {
|
|
|
37fd76 |
@@ -2877,5 +2897,9 @@ static PHP_MINFO_FUNCTION(zip)
|
|
|
37fd76 |
php_info_print_table_row(2, "Zip version", PHP_ZIP_VERSION_STRING);
|
|
|
37fd76 |
- php_info_print_table_row(2, "Libzip version", LIBZIP_VERSION);
|
|
|
37fd76 |
+#if defined(HAVE_LIBZIP)
|
|
|
37fd76 |
+ php_info_print_table_row(2, "Compiled against libzip version", LIBZIP_VERSION);
|
|
|
37fd76 |
+#else
|
|
|
37fd76 |
+ php_info_print_table_row(2, "Bundled libzip version", LIBZIP_VERSION);
|
|
|
37fd76 |
+#endif
|
|
|
37fd76 |
|
|
|
37fd76 |
php_info_print_table_end();
|
|
|
37fd76 |
}
|
|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/php_zip.h.systzip php-5.5.2RC1/ext/zip/php_zip.h
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/php_zip.h.systzip 2013-07-31 10:41:15.000000000 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/php_zip.h 2013-08-08 09:24:07.579567249 +0200
|
|
|
37fd76 |
@@ -28,7 +28,11 @@ extern zend_module_entry zip_module_entr
|
|
|
37fd76 |
#include "TSRM.h"
|
|
|
37fd76 |
#endif
|
|
|
37fd76 |
|
|
|
37fd76 |
+#if defined(HAVE_LIBZIP)
|
|
|
37fd76 |
+#include <zip.h>
|
|
|
37fd76 |
+#else
|
|
|
37fd76 |
#include "lib/zip.h"
|
|
|
37fd76 |
+#endif
|
|
|
37fd76 |
|
|
|
37fd76 |
#define PHP_ZIP_VERSION_STRING "1.11.0"
|
|
|
37fd76 |
|
|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/tests/bug38943.phpt.systzip php-5.5.2RC1/ext/zip/tests/bug38943.phpt
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/tests/bug38943.phpt.systzip 2013-07-31 10:41:15.000000000 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/tests/bug38943.phpt 2013-08-08 09:24:07.579567249 +0200
|
|
|
37fd76 |
@@ -27,7 +27,7 @@ array(1) {
|
|
|
37fd76 |
[0]=>
|
|
|
37fd76 |
int(1)
|
|
|
37fd76 |
}
|
|
|
37fd76 |
-object(myZip)#1 (%d) {
|
|
|
37fd76 |
+object(myZip)#%d (%d) {
|
|
|
37fd76 |
["test":"myZip":private]=>
|
|
|
37fd76 |
int(0)
|
|
|
37fd76 |
["testp"]=>
|
|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/tests/pecl12414.phpt.systzip php-5.5.2RC1/ext/zip/tests/pecl12414.phpt
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/tests/pecl12414.phpt.systzip 2013-07-31 10:41:15.000000000 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/tests/pecl12414.phpt 2013-08-08 09:24:07.579567249 +0200
|
|
|
37fd76 |
@@ -5,6 +5,8 @@ Bug #12414 ( extracting files from damag
|
|
|
37fd76 |
/*$ */
|
|
|
37fd76 |
if(!extension_loaded('zip')) die('skip');
|
|
|
37fd76 |
?>
|
|
|
37fd76 |
+--XFAIL--
|
|
|
37fd76 |
+Doesn't work with system libzip (zip_readfile could not read from ...)
|
|
|
37fd76 |
--FILE--
|
|
|
37fd76 |
|
|
|
37fd76 |
$filename = 'MYLOGOV2.GFX';
|
|
|
37fd76 |
diff -up php-5.5.2RC1/ext/zip/zip_stream.c.systzip php-5.5.2RC1/ext/zip/zip_stream.c
|
|
|
37fd76 |
--- php-5.5.2RC1/ext/zip/zip_stream.c.systzip 2013-07-31 10:41:15.000000000 +0200
|
|
|
37fd76 |
+++ php-5.5.2RC1/ext/zip/zip_stream.c 2013-08-08 09:24:07.580567252 +0200
|
|
|
37fd76 |
@@ -6,7 +6,11 @@
|
|
|
37fd76 |
#if HAVE_ZIP
|
|
|
37fd76 |
#ifdef ZEND_ENGINE_2
|
|
|
37fd76 |
|
|
|
37fd76 |
+#if defined(HAVE_LIBZIP)
|
|
|
37fd76 |
+#include <zip.h>
|
|
|
37fd76 |
+#else
|
|
|
37fd76 |
#include "lib/zip.h"
|
|
|
37fd76 |
+#endif
|
|
|
37fd76 |
|
|
|
37fd76 |
#include "php_streams.h"
|
|
|
37fd76 |
#include "ext/standard/file.h"
|