From: wharmby at uk dot ibm dot com Operating system: Linux RHEL4 PHP version: 5CVS-2007-01-11 (snap) PHP Bug Type: Scripting Engine problem Bug description: php_fopen_primary_script() not thread safe
Description: ------------ The current implementation of php_fopen_primary_script() uses the non-reentrant getpwnam() rather than the re-entrant getpwnam_r(). Therefore calling it on a Linux ZTS enabled build could lead to unpredictable/undesirable results. The code should use the re-entrant version if it is available. The following patch which were built against the latest snapshot (Jan 11 2007, 0730 GMT) modifies the code in main/fopen_wrappers.c to use the re-entrant getpwnam_r if its available: http://pastebin.ca/312969 Fix tested on Linux RHEL4 with Apache 2.0.52 and user_dir set in php.ini The modified code was then driven by specifying the ~user_id in the URL e.g http://localhost/~andy/phpinfo.php. Reproduce code: --------------- Problem found by code inspection. As with most thread safety issues difficult to produce a simple testcase which will show a reproducible crash but current Linux executable is clearly not reentrant and therefore not thread safe. Expected result: ---------------- N/A Actual result: -------------- N/A -- Edit bug report at http://bugs.php.net/?id=40098&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40098&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40098&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40098&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40098&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40098&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40098&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40098&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40098&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40098&r=support Expected behavior: http://bugs.php.net/fix.php?id=40098&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40098&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40098&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40098&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40098&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40098&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40098&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40098&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40098&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40098&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40098&r=mysqlcfg