From c77f783777e0169b2a4b7b9439cad76b372290a3 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 21 Aug 2015 22:26:26 +0200 Subject: 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. --- ext/zip/php_zip.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'ext/zip/php_zip.c') 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; + } } /* }}} */ -- cgit v1.2.1