Skip to content

Commit 1f49902

Browse files
committed
- Fixed bug #53903 (userspace stream stat callback does not separate the
elements of the returned array before converting them).
1 parent 01745fa commit 1f49902

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Bug #53903 streamwrapper/stream_stat causes problems
3+
--FILE--
4+
<?php
5+
6+
class sw {
7+
8+
public function stream_open($path, $mode, $options, &$opened_path) {
9+
return true;
10+
}
11+
12+
public function stream_stat() {
13+
return array(
14+
'atime' => $this->undefined,
15+
);
16+
}
17+
18+
}
19+
stream_wrapper_register('sx', 'sw') or die('failed');
20+
21+
fstat(fopen('sx://test', 'r'));
22+
23+
$s[] = 1; // Cannot use a scalar value as an array
24+
25+
print_r($s);
26+
--EXPECTF--
27+
Notice: Undefined property: sw::$undefined in %s on line %d
28+
Array
29+
(
30+
[0] => 1
31+
)
32+

main/streams/userspace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,7 @@ static int statbuf_from_array(zval *array, php_stream_statbuf *ssb TSRMLS_DC)
855855

856856
#define STAT_PROP_ENTRY_EX(name, name2) \
857857
if (SUCCESS == zend_hash_find(Z_ARRVAL_P(array), #name, sizeof(#name), (void**)&elem)) { \
858+
SEPARATE_ZVAL(elem); \
858859
convert_to_long(*elem); \
859860
ssb->sb.st_##name2 = Z_LVAL_PP(elem); \
860861
}

0 commit comments

Comments
 (0)