Skip to content

Commit 80da0a8

Browse files
committed
add test
1 parent dfa53ae commit 80da0a8

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

sapi/phpdbg/phpdbg_watch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ void *phpdbg_watchpoint_userfaultfd_thread(void *phpdbg_globals) {
316316

317317
struct uffd_msg fault_msg = {0};
318318
while (read(globals->watch_userfaultfd, &fault_msg, sizeof(fault_msg)) == sizeof(fault_msg)) {
319-
void *page = phpdbg_get_page_boundary((char *)(uintptr_t) fault_msg.arg.pagefault.address);
319+
void *page = phpdbg_get_page_boundary((char *)(uintptr_t) fault_msg.arg.pagefault.address);
320320
zend_hash_index_add_empty_element(globals->watchlist_mem, (zend_ulong) page);
321321
struct uffdio_writeprotect unprotect = {
322322
.mode = 0,

sapi/phpdbg/tests/gh13681.phpt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--TEST--
2+
phpdbg_watch null pointer access
3+
--CREDITS--
4+
Yuancheng Jiang
5+
--SKIPIF--
6+
<?php
7+
if (getenv('SKIP_ASAN')) {
8+
die("skip intentionally causes segfaults");
9+
}
10+
?>
11+
--FILE--
12+
<?php
13+
echo "*** Testing array_multisort() : Testing with anonymous arguments ***\n";
14+
var_dump(array_multisort(array(1,3,2,4)));
15+
$xconnect=$GLOBALS[array_rand($GLOBALS)];
16+
echo "Done\n";
17+
$a = [];
18+
$a[0] = 1;
19+
$a[0] = 2;
20+
$a = [0 => 3, 1 => 4];
21+
?>
22+
--PHPDBG--
23+
b 6
24+
r
25+
w a $a
26+
c
27+
q
28+
--EXPECTF--
29+
[Successful compilation of %s]
30+
prompt> [Breakpoint #0 added at %s:%d]
31+
prompt> *** Testing array_multisort() : Testing with anonymous arguments ***
32+
bool(true)
33+
Done
34+
[Breakpoint #0 at %s:%d, hits: 1]
35+
>00006: $a = [];
36+
00007: $a[0] = 1;
37+
00008: $a[0] = 2;
38+
prompt> prompt> [Script ended normally]
39+
prompt>

0 commit comments

Comments
 (0)