Skip to content

Commit c29e86f

Browse files
committed
Merge tag 'php-8.2.22' into was-8.2.x
Tag for php-8.2.22
2 parents c9b6451 + fed0339 commit c29e86f

File tree

79 files changed

+896
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+896
-149
lines changed

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ jobs:
359359
# Test causes a heap-buffer-overflow but I cannot reproduce it locally...
360360
php -r '$c = file_get_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php"); $c = str_replace("public function testSanitizeDeepNestedString()", "/** @group skip */\n public function testSanitizeDeepNestedString()", $c); file_put_contents("src/Symfony/Component/HtmlSanitizer/Tests/HtmlSanitizerCustomTest.php", $c);'
361361
# Buggy FFI test in Symfony, see https://github.com/symfony/symfony/issues/47668
362-
php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("*/\n public function testCastNonTrailingCharPointer()", "* @group skip\n */\n public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);'
362+
php -r '$c = file_get_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php"); $c = str_replace("public function testCastNonTrailingCharPointer()", "/** @group skip */\n public function testCastNonTrailingCharPointer()", $c); file_put_contents("src/Symfony/Component/VarDumper/Tests/Caster/FFICasterTest.php", $c);'
363363
export ASAN_OPTIONS=exitcode=139
364364
export SYMFONY_DEPRECATIONS_HELPER=max[total]=999
365365
X=0

NEWS

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,75 @@
11
PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3+
01 Aug 2024, PHP 8.2.22
4+
5+
- Core:
6+
. Fixed bug GH-13922 (Fixed support for systems with
7+
sysconf(_SC_GETPW_R_SIZE_MAX) == -1). (Arnaud)
8+
. Fixed bug GH-14626 (Fix is_zend_ptr() for huge blocks). (Arnaud)
9+
. Fixed bug GH-14590 (Memory leak in FPM test gh13563-conf-bool-env.phpt.
10+
(nielsdos)
11+
. Fixed OSS-Fuzz #69765. (nielsdos)
12+
. Fixed bug GH-14741 (Segmentation fault in Zend/zend_types.h). (nielsdos)
13+
. Fixed bug GH-14969 (Use-after-free in property coercion with __toString()).
14+
(ilutov)
15+
16+
- Dom:
17+
. Fixed bug GH-14702 (DOMDocument::xinclude() crash). (nielsdos)
18+
19+
- Gd:
20+
. ext/gd/tests/gh10614.phpt: skip if no PNG support. (orlitzky)
21+
. restored warning instead of fata error. (dryabov)
22+
23+
- LibXML:
24+
. Fixed bug GH-14563 (Build failure with libxml2 v2.13.0). (nielsdos)
25+
26+
- Opcache:
27+
. Fixed bug GH-14550 (No warning message when Zend DTrace is enabled that
28+
opcache.jit is implictly disabled). (nielsdos)
29+
30+
- Output:
31+
. Fixed bug GH-14808 (Unexpected null pointer in Zend/zend_string.h with
32+
empty output buffer). (nielsdos)
33+
34+
- PDO:
35+
. Fixed bug GH-14712 (Crash with PDORow access to null property).
36+
(David Carlier)
37+
38+
- Phar:
39+
. Fixed bug GH-14603 (null string from zip entry).
40+
(David Carlier)
41+
42+
- PHPDBG:
43+
. Fixed bug GH-14596 (crashes with ASAN and ZEND_RC_DEBUG=1).
44+
(David Carlier)
45+
. Fixed bug GH-14553 (echo output trimmed at NULL byte). (nielsdos)
46+
47+
- Shmop:
48+
. Fixed bug GH-14537 (shmop Windows 11 crashes the process). (nielsdos)
49+
50+
- SimpleXML:
51+
. Fixed bug GH-14638 (null dereference after XML parsing failure).
52+
(David Carlier)
53+
54+
- SPL:
55+
. Fixed bug GH-14639 (Member access within null pointer in
56+
ext/spl/spl_observer.c). (nielsdos)
57+
58+
- Standard:
59+
. Fix 32-bit wordwrap test failures. (orlitzky)
60+
. Fixed bug GH-14774 (time_sleep_until overflow). (David Carlier)
61+
62+
- Tidy:
63+
. Fix memory leak in tidy_repair_file(). (nielsdos)
64+
65+
- Treewide:
66+
. Fix compatibility with libxml2 2.13.2. (nielsdos)
67+
68+
- XML:
69+
. Move away from to-be-deprecated libxml fields. (nielsdos)
70+
. Fixed bug GH-14834 (Error installing PHP when --with-pear is used).
71+
(nielsdos)
72+
373
04 Jul 2024, PHP 8.2.21
474

575
- Core:
@@ -13,7 +83,7 @@ PHP NEWS
1383
. Fixed bug GH-14549 (Incompatible function pointer type for fclose).
1484
(Ryan Carsten Schmidt)
1585

16-
- BCMatch:
86+
- BCMath:
1787
. Fixed bug (bcpowmod() with mod = -1 returns 1 when it must be 0). (Girgias)
1888

1989
- Curl:

TSRM/tsrm_win32.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ TSRM_API int shmget(key_t key, size_t size, int flags)
709709
CloseHandle(shm->segment);
710710
}
711711
UnmapViewOfFile(shm->descriptor);
712+
shm->descriptor = NULL;
712713
return -1;
713714
}
714715

@@ -744,8 +745,8 @@ TSRM_API int shmdt(const void *shmaddr)
744745
shm->descriptor->shm_lpid = getpid();
745746
shm->descriptor->shm_nattch--;
746747

747-
ret = 1;
748-
if (!ret && shm->descriptor->shm_nattch <= 0) {
748+
ret = 0;
749+
if (shm->descriptor->shm_nattch <= 0) {
749750
ret = UnmapViewOfFile(shm->descriptor) ? 0 : -1;
750751
shm->descriptor = NULL;
751752
}

Zend/tests/gh14626.phpt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
--TEST--
2+
GH-14626: is_zend_ptr() may crash for non-zend ptrs when huge blocks exist
3+
--EXTENSIONS--
4+
zend_test
5+
--FILE--
6+
<?php
7+
8+
// Ensure there is at least one huge_block
9+
$str = str_repeat('a', 2*1024*1024);
10+
11+
// Check that is_zend_ptr() does not crash
12+
zend_test_is_zend_ptr(0);
13+
zend_test_is_zend_ptr(1<<30);
14+
15+
?>
16+
==DONE==
17+
--EXPECT--
18+
==DONE==

Zend/tests/gh14969.phpt

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
--TEST--
2+
GH-14969: Crash on coercion with throwing __toString()
3+
--FILE--
4+
<?php
5+
6+
class C {
7+
public function __toString() {
8+
global $c;
9+
$c = [];
10+
throw new Exception(__METHOD__);
11+
}
12+
}
13+
14+
class D {
15+
public string $prop;
16+
}
17+
18+
$c = new C();
19+
$d = new D();
20+
try {
21+
$d->prop = $c;
22+
} catch (Throwable $e) {
23+
echo $e->getMessage(), "\n";
24+
}
25+
var_dump($d);
26+
27+
$c = new C();
28+
$d->prop = 'foo';
29+
try {
30+
$d->prop = $c;
31+
} catch (Throwable $e) {
32+
echo $e->getMessage(), "\n";
33+
}
34+
var_dump($d);
35+
36+
?>
37+
--EXPECTF--
38+
C::__toString
39+
object(D)#%d (0) {
40+
["prop"]=>
41+
uninitialized(string)
42+
}
43+
C::__toString
44+
object(D)#2 (1) {
45+
["prop"]=>
46+
string(3) "foo"
47+
}

Zend/tests/oss-fuzz-69765.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
OSS-Fuzz #69765: yield reference to nullsafe chain
3+
--FILE--
4+
<?php
5+
function &test($object) {
6+
yield $object->y?->y;
7+
}
8+
?>
9+
--EXPECTF--
10+
Fatal error: Cannot take reference of a nullsafe chain in %s on line %d

Zend/zend.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#ifndef ZEND_H
2121
#define ZEND_H
2222

23-
#define ZEND_VERSION "4.2.21"
23+
#define ZEND_VERSION "4.2.22"
2424

2525
#define ZEND_ENGINE_3
2626

Zend/zend_alloc.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,17 +2470,15 @@ ZEND_API bool is_zend_ptr(const void *ptr)
24702470
} while (chunk != AG(mm_heap)->main_chunk);
24712471
}
24722472

2473-
if (AG(mm_heap)->huge_list) {
2474-
zend_mm_huge_list *block = AG(mm_heap)->huge_list;
2475-
2476-
do {
2477-
if (ptr >= (void*)block
2478-
&& ptr < (void*)((char*)block + block->size)) {
2479-
return 1;
2480-
}
2481-
block = block->next;
2482-
} while (block != AG(mm_heap)->huge_list);
2473+
zend_mm_huge_list *block = AG(mm_heap)->huge_list;
2474+
while (block) {
2475+
if (ptr >= (void*)block
2476+
&& ptr < (void*)((char*)block + block->size)) {
2477+
return 1;
2478+
}
2479+
block = block->next;
24832480
}
2481+
24842482
return 0;
24852483
}
24862484

Zend/zend_compile.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,13 @@ static bool zend_ast_is_short_circuited(const zend_ast *ast)
23132313
}
23142314
}
23152315

2316+
static void zend_assert_not_short_circuited(const zend_ast *ast)
2317+
{
2318+
if (zend_ast_is_short_circuited(ast)) {
2319+
zend_error_noreturn(E_COMPILE_ERROR, "Cannot take reference of a nullsafe chain");
2320+
}
2321+
}
2322+
23162323
/* Mark nodes that are an inner part of a short-circuiting chain.
23172324
* We should not perform a "commit" on them, as it will be performed by the outer-most node.
23182325
* We do this to avoid passing down an argument in various compile functions. */
@@ -3301,9 +3308,8 @@ static void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
33013308
if (!zend_is_variable_or_call(expr_ast)) {
33023309
zend_error_noreturn(E_COMPILE_ERROR,
33033310
"Cannot assign reference to non referenceable value");
3304-
} else if (zend_ast_is_short_circuited(expr_ast)) {
3305-
zend_error_noreturn(E_COMPILE_ERROR,
3306-
"Cannot take reference of a nullsafe chain");
3311+
} else {
3312+
zend_assert_not_short_circuited(expr_ast);
33073313
}
33083314

33093315
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);
@@ -3345,9 +3351,7 @@ static void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
33453351
zend_error_noreturn(E_COMPILE_ERROR, "Cannot re-assign $this");
33463352
}
33473353
zend_ensure_writable_variable(target_ast);
3348-
if (zend_ast_is_short_circuited(source_ast)) {
3349-
zend_error_noreturn(E_COMPILE_ERROR, "Cannot take reference of a nullsafe chain");
3350-
}
3354+
zend_assert_not_short_circuited(source_ast);
33513355
if (is_globals_fetch(source_ast)) {
33523356
zend_error_noreturn(E_COMPILE_ERROR, "Cannot acquire reference to $GLOBALS");
33533357
}
@@ -5023,10 +5027,7 @@ static void zend_compile_return(zend_ast *ast) /* {{{ */
50235027
expr_node.op_type = IS_CONST;
50245028
ZVAL_NULL(&expr_node.u.constant);
50255029
} else if (by_ref && zend_is_variable(expr_ast)) {
5026-
if (zend_ast_is_short_circuited(expr_ast)) {
5027-
zend_error_noreturn(E_COMPILE_ERROR, "Cannot take reference of a nullsafe chain");
5028-
}
5029-
5030+
zend_assert_not_short_circuited(expr_ast);
50305031
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);
50315032
} else {
50325033
zend_compile_expr(&expr_node, expr_ast);
@@ -9326,6 +9327,7 @@ static void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
93269327

93279328
if (value_ast) {
93289329
if (returns_by_ref && zend_is_variable(value_ast)) {
9330+
zend_assert_not_short_circuited(value_ast);
93299331
zend_compile_var(&value_node, value_ast, BP_VAR_W, 1);
93309332
} else {
93319333
zend_compile_expr(&value_node, value_ast);

Zend/zend_execute.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,6 +3122,9 @@ static zend_always_inline void zend_fetch_property_address(zval *result, zval *c
31223122
}
31233123
}
31243124

3125+
/* Pointer on property callback is required */
3126+
ZEND_ASSERT(zobj->handlers->get_property_ptr_ptr != NULL);
3127+
31253128
if (prop_op_type == IS_CONST) {
31263129
name = Z_STR_P(prop_ptr);
31273130
} else {

0 commit comments

Comments
 (0)