Skip to content

Commit 7cae94d

Browse files
committed
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: add test for bug #70898 Also protects this one Update NEWS Re-fixed #70895 Revert "Fixed bug Bug #70895 null ptr deref and segfault" Revert "refix bug #70895" Revert "Fixed bug #70898 (SIGBUS/GPF zend_mm_alloc_small (zend_alloc.c:1291))" Fixed bug #70898 (SIGBUS/GPF zend_mm_alloc_small (zend_alloc.c:1291)) Using default port in ldap_connect when NULL is passed (this was the behavior prior to 5.6.11) update NEWS refix bug #70895 Fixed bug Bug #70895 null ptr deref and segfault
2 parents 63c4414 + 9b0775d commit 7cae94d

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

Zend/tests/bug70895.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #70895 null ptr deref and segfault with crafted calable
3+
--FILE--
4+
<?php
5+
6+
array_map("%n", 0);
7+
array_map("%n %i", 0);
8+
array_map("%n %i aoeu %f aoeu %p", 0);
9+
?>
10+
--EXPECTREGEX--
11+
Warning: array_map\(\) expects parameter 1 to be a valid callback, function '%n' not found or invalid function name in .+
12+
13+
Warning: array_map\(\) expects parameter 1 to be a valid callback, function '%n %i' not found or invalid function name in .+
14+
15+
Warning: array_map\(\) expects parameter 1 to be a valid callback, function '%n %i aoeu %f aoeu %p' not found or invalid function name in .+bug70895.php on line \d+

Zend/tests/bug70898.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
Bug #70895 null ptr deref and segfault with crafted calable
3+
--FILE--
4+
<?php
5+
function m($f,$a){
6+
return array_map($f,0);
7+
}
8+
9+
echo implode(m("",m("",m("",m("",m("0000000000000000000000000000000000",("")))))));
10+
?>
11+
--EXPECTF--
12+
Warning: array_map() expects parameter 1 to be a valid callback, function '0000000000000000000000000000000000' not found or invalid function name in %sbug70898.php on line %d
13+
14+
Warning: array_map() expects parameter 1 to be a valid callback, function '' not found or invalid function name in %sbug70898.php on line %d
15+
16+
Warning: array_map() expects parameter 1 to be a valid callback, function '' not found or invalid function name in %sbug70898.php on line %d
17+
18+
Warning: array_map() expects parameter 1 to be a valid callback, function '' not found or invalid function name in %sbug70898.php on line %d
19+
20+
Warning: array_map() expects parameter 1 to be a valid callback, function '' not found or invalid function name in %sbug70898.php on line %d
21+
22+
Warning: implode(): Argument must be an array in %sbug70898.php on line %d

Zend/zend.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ ZEND_API ZEND_COLD void zend_throw_error(zend_class_entry *exception_ce, const c
13161316
if (EG(current_execute_data) && !CG(in_compilation)) {
13171317
zend_throw_exception(exception_ce, message, 0);
13181318
} else {
1319-
zend_error(E_ERROR, message);
1319+
zend_error(E_ERROR, "%s", message);
13201320
}
13211321

13221322
efree(message);
@@ -1346,7 +1346,7 @@ ZEND_API ZEND_COLD void zend_internal_type_error(zend_bool throw_exception, cons
13461346
if (throw_exception) {
13471347
zend_throw_exception(zend_ce_type_error, message, 0);
13481348
} else {
1349-
zend_error(E_WARNING, message);
1349+
zend_error(E_WARNING, "%s", message);
13501350
}
13511351
efree(message);
13521352

ext/ldap/ldap.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@ PHP_FUNCTION(ldap_connect)
345345
RETURN_FALSE;
346346
}
347347
#endif
348+
if (!port) {
349+
port = LDAP_PORT;
350+
}
348351

349352
if (LDAPG(max_links) != -1 && LDAPG(num_links) >= LDAPG(max_links)) {
350353
php_error_docref(NULL, E_WARNING, "Too many open links (%pd)", LDAPG(num_links));

0 commit comments

Comments
 (0)