#39623 [NEW]: putenv() function not thread safe on Linux
| From: | wharmby at uk dot ibm dot com | Date: | Fri, 24 Nov 2006 17:29:38 +0000 |
| Subject: | #39623 [NEW]: putenv() function not thread safe on Linux | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-105421@lists.php.net to get a copy of this message | ||
From: wharmby at uk dot ibm dot com
Operating system: Linux RHEL4
PHP version: 5CVS-2006-11-24 (CVS)
PHP Bug Type: Unknown/Other Function
Bug description: putenv() function not thread safe on Linux
Description:
------------
The implementation of putenv() in standard/basic_function.c
uses the C library function strtok(). Whilst this is OK when
compiling with Microsoft Visual C because PHP is linked with
the Mutithreaded C run-time library (/MD or /MDd option) whether ZTS is
enabled or not, the gcc version of strtok() is not thread safe and a
separate function strtok_r() is provided should thread safety be
required.
Easily resolved without the need for #if def's in code by
changing code to call the php function php_strtok_r()
as a number of other extensions already do.
Patch to fix the code is here: http://pastebin.ca/256777
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=39623&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39623&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39623&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39623&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39623&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39623&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39623&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39623&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39623&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39623&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39623&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39623&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39623&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39623&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39623&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39623&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39623&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39623&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39623&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39623&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39623&r=mysqlcfg