com php-src: Merge branch 'PHP-7.2' into PHP-7.3: ext/phar/tests/bug79797.phar ext/phar/tests/bug79797.phpt ext/phar/zip.c ext/standard/image.c
ext/standard/tests/image/bug79877.phpt

From: Date: Tue, 04 Aug 2020 08:20:13 +0000
Subject: com php-src: Merge branch 'PHP-7.2' into PHP-7.3: ext/phar/tests/bug79797.phar ext/phar/tests/bug79797.phpt ext/phar/zip.c ext/standard/image.c
ext/standard/tests/image/bug79877.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-112538@lists.php.net to get a copy of this message
Commit: ef648e31829ee4117845d30bdcc90e543f6466b4 Author: Stanislav Malyshev <stas@php.net> Sun, 2 Aug 2020 23:56:37 -0700 Committer: Derick Rethans <github@derickrethans.nl> Tue, 4 Aug 2020 09:20:13 +0100 Parents: e7a3e0429d538fdba4000f2c5b87ce3d75a6214a Branches: PHP-7..4.9 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ef648e31829ee4117845d30bdcc90e543f6466b4 Log: Merge branch 'PHP-7..2' into PHP-7.3 * PHP-7.2: Fix #79877: getimagesize function silently truncates after a null byte Fix #79797: Use of freed hash key in the phar_parse_zipfile function Bugs: https://bugs.php.net/79877 https://bugs.php.net/79797 Changed paths: A ext/phar/tests/bug79797..phar A ext/phar/tests/bug79797.phpt M ext/phar/zip.c M ext/standard/image.c A ext/standard/tests/image/bug79877.phpt Diff: diff --git a/ext/phar/tests/bug79797.phar b/ext/phar/tests/bug79797.phar new file mode 100644 index 0000000000..21d43d9eeb Binary files /dev/null and b/ext/phar/tests/bug79797.phar differ diff --git a/ext/phar/tests/bug79797.phpt b/ext/phar/tests/bug79797.phpt new file mode 100644 index 0000000000..761e5379e0 --- /dev/null +++ b/ext/phar/tests/bug79797.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #79797 (Use of freed hash key in the phar_parse_zipfile function) +--SKIPIF-- +<?php +if (!extension_loaded('phar')) die('skip phar extension not available'); +?> +--INI-- +phar.cache_list={PWD}/bug79797.phar +--FILE-- +<?php +echo "done\n"; +?> +--EXPECT-- +done diff --git a/ext/phar/zip.c b/ext/phar/zip.c index e086354b11..b241c0589b 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -712,7 +712,7 @@ foundit: efree(actual_alias); } - zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata); + zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), mydata->alias, mydata->alias_len, mydata); } else { phar_archive_data *fd_ptr; diff --git a/ext/standard/image.c b/ext/standard/image.c index aaaf81ae9e..eeb48ea223 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -1496,6 +1496,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) { Z_PARAM_ZVAL(info) ZEND_PARSE_PARAMETERS_END(); + if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) { + php_error_docref(NULL, E_WARNING, "Invalid path"); + return; + } + if (argc == 2) { info = zend_try_array_init(info); if (!info) { diff --git a/ext/standard/tests/image/bug79877.phpt b/ext/standard/tests/image/bug79877.phpt new file mode 100644 index 0000000000..92e93e59e5 --- /dev/null +++ b/ext/standard/tests/image/bug79877.phpt @@ -0,0 +1,9 @@ +--TEST-- +Bug #79877 (getimagesize function silently truncates after a null byte) +--FILE-- +<?php +var_dump(getimagesize("/tmp/a.png\0xx")); +?> +--EXPECTF-- +Warning: getimagesize(): Invalid path in %s on line %d +NULL

« previous php.cvs (#112538) next »