Skip to content

Commit 5b29af5

Browse files
committed
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
2 parents 1e0bc6e + ff577b0 commit 5b29af5

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

ext/phar/tests/bug79797.phar

274 Bytes
Binary file not shown.

ext/phar/tests/bug79797.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Bug #79797 (Use of freed hash key in the phar_parse_zipfile function)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('phar')) die('skip phar extension not available');
6+
?>
7+
--INI--
8+
phar.cache_list={PWD}/bug79797.phar
9+
--FILE--
10+
<?php
11+
echo "done\n";
12+
?>
13+
--EXPECT--
14+
done

ext/phar/zip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
705705
efree(actual_alias);
706706
}
707707

708-
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), actual_alias, mydata->alias_len, mydata);
708+
zend_hash_str_add_ptr(&(PHAR_G(phar_alias_map)), mydata->alias, mydata->alias_len, mydata);
709709
} else {
710710
phar_archive_data *fd_ptr;
711711

ext/standard/image.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,11 @@ static void php_getimagesize_from_any(INTERNAL_FUNCTION_PARAMETERS, int mode) {
14961496
Z_PARAM_ZVAL_DEREF(info)
14971497
ZEND_PARSE_PARAMETERS_END();
14981498

1499+
if (mode == FROM_PATH && CHECK_NULL_PATH(input, input_len)) {
1500+
php_error_docref(NULL, E_WARNING, "Invalid path");
1501+
return;
1502+
}
1503+
14991504
if (argc == 2) {
15001505
zval_ptr_dtor(info);
15011506
array_init(info);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #79877 (getimagesize function silently truncates after a null byte)
3+
--FILE--
4+
<?php
5+
var_dump(getimagesize("/tmp/a.png\0xx"));
6+
?>
7+
--EXPECTF--
8+
Warning: getimagesize(): Invalid path in %s on line %d
9+
NULL

0 commit comments

Comments
 (0)