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
This commit is contained in:
Stanislav Malyshev 2020-08-02 23:56:37 -07:00
commit 5b29af5c78
5 changed files with 29 additions and 1 deletions

Binary file not shown.

View file

@ -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

View file

@ -705,7 +705,7 @@ foundit:
efree(actual_alias); 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 { } else {
phar_archive_data *fd_ptr; phar_archive_data *fd_ptr;

View file

@ -1496,6 +1496,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
Z_PARAM_ZVAL_DEREF(info) Z_PARAM_ZVAL_DEREF(info)
ZEND_PARSE_PARAMETERS_END(); 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) { if (argc == 2) {
zval_ptr_dtor(info); zval_ptr_dtor(info);
array_init(info); array_init(info);

View file

@ -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