summaryrefslogtreecommitdiff
path: root/ext/zip/php_zip.c
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2020-10-20 12:31:58 +0200
committerRemi Collet <remi@php.net>2020-11-06 11:00:43 +0100
commitd65a520b1d0b663d984ae14d75eab29aef7e11cc (patch)
treed976e87d170d27e840382944d8426a5a7ae6483a /ext/zip/php_zip.c
parent98e4f9466d979c2cc6ea42193ec038f5d08915c8 (diff)
downloadphp-git-d65a520b1d0b663d984ae14d75eab29aef7e11cc.tar.gz
Raise E_WARNING on PHP related errors
If Zip operations fails due to PHP error conditions before libzip even has been called, there is no meaningful indication what failed; the functions just return false, and the Zip status indicated that no error did occur. Therefore we raise `E_WARNING` in these cases. Closes GH-6356.
Diffstat (limited to 'ext/zip/php_zip.c')
-rw-r--r--ext/zip/php_zip.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c
index cac33818c7..92272d270f 100644
--- a/ext/zip/php_zip.c
+++ b/ext/zip/php_zip.c
@@ -288,11 +288,13 @@ static int php_zip_add_file(ze_zip_object *obj, const char *filename, size_t fil
}
if (!expand_filepath(filename, resolved_path)) {
+ php_error_docref(NULL, E_WARNING, "No such file or directory");
return -1;
}
php_stat(resolved_path, strlen(resolved_path), FS_EXISTS, &exists_flag);
if (Z_TYPE(exists_flag) == IS_FALSE) {
+ php_error_docref(NULL, E_WARNING, "No such file or directory");
return -1;
}
@@ -1163,6 +1165,7 @@ PHP_FUNCTION(zip_open)
}
if(!expand_filepath(ZSTR_VAL(filename), resolved_path)) {
+ php_error_docref(NULL, E_WARNING, "No such file or directory");
RETURN_FALSE;
}
@@ -1444,6 +1447,7 @@ PHP_METHOD(ZipArchive, open)
}
if (!(resolved_path = expand_filepath(ZSTR_VAL(filename), NULL))) {
+ php_error_docref(NULL, E_WARNING, "No such file or directory");
RETURN_FALSE;
}