Merge branch 'PHP-7.4'

* PHP-7.4:
  Fix #78386: fstat mode has unexpected value on PHP 7.4
This commit is contained in:
Christoph M. Becker 2019-08-20 16:04:50 +02:00
commit 773957c36f
2 changed files with 28 additions and 1 deletions

View file

@ -0,0 +1,14 @@
--TEST--
Bug #78386 (fstat mode has unexpected value on PHP 7.4)
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) != 'WIN') die("skip this test is for Windows platforms only");
?>
--FILE--
<?php
$handle = popen('dir', 'r');
$stat = fstat($handle);
var_dump(decoct($stat['mode']));
?>
--EXPECT--
string(5) "10666"

View file

@ -942,7 +942,20 @@ static int php_win32_ioutil_fstat_int(HANDLE h, php_win32_ioutil_stat_t *buf, co
}
if ((data->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0) {
buf->st_mode |= is_dir ? (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6)) : S_IFREG;
if (is_dir) {
buf->st_mode |= (S_IFDIR|S_IEXEC|(S_IEXEC>>3)|(S_IEXEC>>6));
} else {
switch (GetFileType(h)) {
case FILE_TYPE_CHAR:
buf->st_mode |= S_IFCHR;
break;
case FILE_TYPE_PIPE:
buf->st_mode |= S_IFIFO;
break;
default:
buf->st_mode |= S_IFREG;
}
}
buf->st_mode |= (data->dwFileAttributes & FILE_ATTRIBUTE_READONLY) ? (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)) : (S_IREAD|(S_IREAD>>3)|(S_IREAD>>6)|S_IWRITE|(S_IWRITE>>3)|(S_IWRITE>>6));
}