summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2015-08-21 22:26:26 +0200
committerChristoph M. Becker <cmb@php.net>2015-09-05 00:34:10 +0200
commitc77f783777e0169b2a4b7b9439cad76b372290a3 (patch)
treec1370e0d681d44fa142b051f6dbbd5ef26180a7c /ext/zip/php_zip.c
parent4b1dff6f438f84f7694df701b68744edbdd86153 (diff)
downloadphp-git-c77f783777e0169b2a4b7b9439cad76b372290a3.tar.gz
Fix #70322: ZipArchive::close() doesn't indicate errors
If an archive can't be written, ZipArchive::close() nonetheless returns TRUE. We fix the return value to properly return success, and additionally raise a warning on failure.
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index d4f77eb4ed..0355db48e5 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -1616,6 +1616,7 @@ static ZIPARCHIVE_METHOD(close)
struct zip *intern;
zval *this = getThis();
ze_zip_object *ze_obj;
+ int err;
if (!this) {
RETURN_FALSE;
@@ -1625,7 +1626,8 @@ static ZIPARCHIVE_METHOD(close)
ze_obj = (ze_zip_object*) zend_object_store_get_object(this TSRMLS_CC);
- if (zip_close(intern)) {
+ if (err = zip_close(intern)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, zip_strerror(intern));
zip_discard(intern);
}
@@ -1634,7 +1636,11 @@ static ZIPARCHIVE_METHOD(close)
ze_obj->filename_len = 0;
ze_obj->za = NULL;
- RETURN_TRUE;
+ if (!err) {
+ RETURN_TRUE;
+ } else {
+ RETURN_FALSE;
+ }
}
/* }}} */