From: wharmby at uk dot ibm dot com Operating system: Linux RHEL4 PHP version: 5CVS-2007-01-09 (snap) PHP Bug Type: Scripting Engine problem Bug description: php_get_current_user() not thread safe
Description: ------------ The current implementation of php_get_current_user() uses the non-reentrant getpwuid() rather than the reentrant getpwuid_r(). Therefore issuing on Linux in a 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 9 2007, 1330 GMT) modifies the code in main/safe_mode.c to use the re-entrant getpwuid_r if its available: http://pastebin.ca/311144 Following makes necessary associated change to configure.in: http://pastebin.ca/311140 Fix tested on Linux RHEL with mysql extension enabled and sql.safe_mode=On in php.ini. The modified code can then easily be invoked by issuing mysql_connect(). 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. Expected result: ---------------- N/A Actual result: -------------- N/A -- Edit bug report at http://bugs.php.net/?id=40079&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=40079&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=40079&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=40079&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=40079&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=40079&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=40079&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=40079&r=needscript Try newer version: http://bugs.php.net/fix.php?id=40079&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=40079&r=support Expected behavior: http://bugs.php.net/fix.php?id=40079&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=40079&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=40079&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=40079&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40079&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=40079&r=dst IIS Stability: http://bugs.php.net/fix.php?id=40079&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=40079&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=40079&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=40079&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=40079&r=mysqlcfg