com php-src: Raise E_WARNING on PHP related errors: ext/zip/php_zip.c ext/zip/tests/bug64342_ 0.phpt ext/zip/tests/bug64342_1-mb.phpt
ext/zip/tests/bug64342_1.phpt

From: Date: Fri, 06 Nov 2020 10:00:43 +0000
Subject: com php-src: Raise E_WARNING on PHP related errors: ext/zip/php_zip.c ext/zip/tests/bug64342_ 0.phpt ext/zip/tests/bug64342_1-mb.phpt
ext/zip/tests/bug64342_1.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-114079@lists.php.net to get a copy of this message
Commit: d65a520b1d0b663d984ae14d75eab29aef7e11cc Author: Christoph M. Becker <cmbecker69@gmx.de> Tue, 20 Oct 2020 12:31:58 +0200 Committer: Remi Collet <remi@php.net> Fri, 6 Nov 2020 11:00:43 +0100 Parents: 98e4f9466d979c2cc6ea42193ec038f5d08915c8 Branches: PHP-8.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d65a520b1d0b663d984ae14d75eab29aef7e11cc Log: 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. Changed paths: M ext/zip/php_zip.c M ext/zip/tests/bug64342_0.phpt M ext/zip/tests/bug64342_1-mb.phpt M ext/zip/tests/bug64342_1.phpt Diff: diff --git a/ext/zip/php_zip.c b/ext/zip/php_zip.c index cac33818c7f..92272d270fe 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; } diff --git a/ext/zip/tests/bug64342_0.phpt b/ext/zip/tests/bug64342_0.phpt index 43f60f5d7c5..751fb9c4ba4 100644 --- a/ext/zip/tests/bug64342_0.phpt +++ b/ext/zip/tests/bug64342_0.phpt @@ -38,6 +38,8 @@ DONE ?> --EXPECTF-- %s.txt + +Warning: ZipArchive::addFile(): No such file or directory in %s on line %d add failed close ok DONE diff --git a/ext/zip/tests/bug64342_1-mb.phpt b/ext/zip/tests/bug64342_1-mb.phpt index 4884c9fe5f3..9efd046315e 100644 --- a/ext/zip/tests/bug64342_1-mb.phpt +++ b/ext/zip/tests/bug64342_1-mb.phpt @@ -37,6 +37,7 @@ if ($zip->status == ZIPARCHIVE::ER_OK) { } @unlink($file); ?> ---EXPECT-- +--EXPECTF-- +Warning: ZipArchive::addFile(): No such file or directory in %s on line %d failed OK diff --git a/ext/zip/tests/bug64342_1.phpt b/ext/zip/tests/bug64342_1.phpt index 6b923d3ef1a..1fff3da26d6 100644 --- a/ext/zip/tests/bug64342_1.phpt +++ b/ext/zip/tests/bug64342_1.phpt @@ -37,6 +37,7 @@ if ($zip->status == ZIPARCHIVE::ER_OK) { } @unlink($file); ?> ---EXPECT-- +--EXPECTF-- +Warning: ZipArchive::addFile(): No such file or directory in %s on line %d failed OK

« previous php.cvs (#114079) next »