Bug #77552 [NEW]: Unintialized php_stream_statbuf in stat functions

From: Date: Thu, 31 Jan 2019 22:19:18 +0000
Subject: Bug #77552 [NEW]: Unintialized php_stream_statbuf in stat functions
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-219314@lists.php.net to get a copy of this message
From: john-stevenson at blueyonder dot co dot uk Operating system: Windows 10 PHP version: 7.3.1 Package: Filesystem function related Bug Type: Bug Bug description:Unintialized php_stream_statbuf in stat functions Description: ------------ The php_stream_statbuf that is used in the filepath stat functions is uninitialized in function 'php_stat' (ext\standard\filestat.c). This can result in random st_mode values, when calling lstat on a NTFS junction. The 'php_sys_stat_ex' function (zend\zend_virtual_cwd.c) sets the st_mode for everything except a junction, so the uninitialized value is returned. The test script below just illustrates that it is uninitialized by using a debug build. On release builds the script will show the 'expected' mode value of 0, but when used in more complex scenarios (like a test suite) different values can be returned for junctions. For example, from my error log, while trying to track this down: [31-Jan-2019 21:52:39 UTC] PHP 7.3.1 [31-Jan-2019 21:52:39 UTC] mode: 53467, composer-test-27485c536e26d95fa/junction [31-Jan-2019 21:52:39 UTC] mode: 1508, composer-test-27485c536e26d95fa/junction [31-Jan-2019 21:52:39 UTC] mode: 18252, composer-test-27485c536e26d95fa/junction Of course, since there is no S_IFJUNC, it is hard to know what the 'expected' st_mode value should be. However Composer uses it to check for a junction (if it is a directory, not a link and not S_ISDIR from lstat's st_mode) and our tests are sometimes now failing on PHP 7.3 Test script: --------------- Create a junction: mkdir /J path/to/junction path/to/target Compile php with --enable-debug Run: php.exe -r "print_r(lstat('path/to/junction'));" Expected result: ---------------- ... [mode] => 0 ... Actual result: -------------- ... [mode] => 52428 ... -- Edit bug report at https://bugs.php.net/bug.php?id=77552&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77552&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77552&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77552&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=77552&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=77552&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=77552&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=77552&r=needscript Try newer version: https://bugs.php.net/fix.php?id=77552&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=77552&r=support Expected behavior: https://bugs.php.net/fix.php?id=77552&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=77552&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=77552&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=77552&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77552&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=77552&r=dst IIS Stability: https://bugs.php.net/fix.php?id=77552&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=77552&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=77552&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=77552&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=77552&r=mysqlcfg

« previous php.bugs (#219314) next »