summaryrefslogtreecommitdiff
path: root/ext/zip/lib/zip_fdopen.c
diff options
context:
space:
mode:
authorRemi Collet <remi@php.net>2013-11-04 13:23:36 +0100
committerRemi Collet <remi@php.net>2013-11-04 13:23:36 +0100
commit5dc37b351085a7b8cdc30ef2ebb349c8e5df4e2c (patch)
tree33357220b91d8553c0978e6392385e0fb8e49028 /ext/zip/lib/zip_fdopen.c
parent2f555b8e606b5f09d635cef4d3fcbcd6939adae2 (diff)
downloadphp-git-5dc37b351085a7b8cdc30ef2ebb349c8e5df4e2c.tar.gz
Sync ext/zip with pecl/zip version 1.3.2
- update libzip to version 1.11.1. We don't use any private symbol anymore - new method ZipArchive::setPassword($password) - add --with-libzip option to build with system libzip
Diffstat (limited to 'ext/zip/lib/zip_fdopen.c')
-rw-r--r--ext/zip/lib/zip_fdopen.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/ext/zip/lib/zip_fdopen.c b/ext/zip/lib/zip_fdopen.c
index df70f27561..bda9aabac4 100644
--- a/ext/zip/lib/zip_fdopen.c
+++ b/ext/zip/lib/zip_fdopen.c
@@ -37,11 +37,24 @@
-ZIP_EXTERN(struct zip *)
-zip_fdopen(int fd_orig, int flags, int *zep)
+ZIP_EXTERN struct zip *
+zip_fdopen(int fd_orig, int _flags, int *zep)
{
int fd;
FILE *fp;
+ unsigned int flags;
+
+ if (_flags < 0) {
+ if (zep)
+ *zep = ZIP_ER_INVAL;
+ return NULL;
+ }
+ flags = (unsigned int)_flags;
+
+ if (flags & ZIP_TRUNCATE) {
+ *zep = ZIP_ER_INVAL;
+ return NULL;
+ }
/* We dup() here to avoid messing with the passed in fd.
We could not restore it to the original state in case of error. */
@@ -58,5 +71,5 @@ zip_fdopen(int fd_orig, int flags, int *zep)
}
close(fd_orig);
- return _zip_open(NULL, fp, flags, ZIP_AFL_RDONLY, zep);
+ return _zip_open(NULL, fp, flags, zep);
}