Skip to content

Commit fe4d724

Browse files
johnstevensonnikic
authored andcommitted
Fix #77552: Uninitialized buffer in stat functions
1 parent 92055ca commit fe4d724

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ PHP NEWS
1010
. Support Oracle Database tracing attributes ACTION, MODULE,
1111
CLIENT_INFO, and CLIENT_IDENTIFIER. (Cameron Porter)
1212

13+
- Standard:
14+
. Fixed bug #77552 (Unintialized php_stream_statbuf in stat functions).
15+
(John Stevenson)
16+
1317
07 Feb 2019, PHP 7.2.15
1418

1519
- Core:

ext/standard/tests/file/bug77552.phpt

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Bug #77552 Unintialized php_stream_statbuf in stat functions
3+
--SKIPIF--
4+
<?php
5+
if (substr(PHP_OS, 0, 3) != 'WIN') {
6+
die('skip windows only test');
7+
}
8+
?>
9+
--FILE--
10+
<?php
11+
// Check lstat on a Windows junction to ensure that st_mode is zero
12+
$tmpDir = __DIR__.'/test-bug77552';
13+
14+
$target = $tmpDir.'/folder/target';
15+
mkdir($target, 0777, true);
16+
17+
$junction = $tmpDir.'/junction';
18+
$cmd = sprintf('mklink /J "%s" "%s"', $junction, $target);
19+
exec($cmd);
20+
21+
$stat = lstat($junction);
22+
var_dump($stat['mode']);
23+
24+
?>
25+
--CLEAN--
26+
<?php
27+
$tmpDir = __DIR__.'/test-bug77552';
28+
$cmd = sprintf('rmdir /S /Q "%s"', $tmpDir);
29+
exec($cmd);
30+
?>
31+
--EXPECT--
32+
int(0)

main/streams/streams.c

+2
Original file line numberDiff line numberDiff line change
@@ -1887,6 +1887,8 @@ PHPAPI int _php_stream_stat_path(const char *path, int flags, php_stream_statbuf
18871887
const char *path_to_open = path;
18881888
int ret;
18891889

1890+
memset(ssb, 0, sizeof(*ssb));
1891+
18901892
if (!(flags & PHP_STREAM_URL_STAT_NOCACHE)) {
18911893
/* Try to hit the cache first */
18921894
if (flags & PHP_STREAM_URL_STAT_LINK) {

0 commit comments

Comments
 (0)