#39623 [Opn]: putenv() function not thread safe on Linux
| From: | wharmby at uk dot ibm dot com | Date: | Sat, 25 Nov 2006 14:35:46 +0000 |
| Subject: | #39623 [Opn]: putenv() function not thread safe on Linux | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-105442@lists.php.net to get a copy of this message | ||
ID: 39623
User updated by: wharmby at uk dot ibm dot com
Reported By: wharmby at uk dot ibm dot com
Status: Open
Bug Type: Unknown/Other Function
Operating System: Linux RHEL4
PHP Version: 5CVS-2006-11-24 (CVS)
New Comment:
Sorry uploaded wrong version of patch above. Here is correct patch:
http://pastebin.ca/257571
Previous Comments:
------------------------------------------------------------------------
[2006-11-24 17:29:38] wharmby at uk dot ibm dot com
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 this bug report at http://bugs.php.net/?id=39623&edit=1