#39623 [Opn->Csd]: putenv() function not thread safe on Linux

From: Date: Sun, 26 Nov 2006 17:03:22 +0000
Subject: #39623 [Opn->Csd]: putenv() function not thread safe on Linux
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105449@lists.php.net to get a copy of this message
ID: 39623 Updated by: iliaa@php.net Reported By: wharmby at uk dot ibm dot com -Status: Open +Status: Closed Bug Type: Unknown/Other Function Operating System: Linux RHEL4 PHP Version: 5CVS-2006-11-24 (CVS) New Comment: This bug has been fixed in CVS. Snapshots of the sources are packaged every three hours; this change will be in the next snapshot. You can grab the snapshot at http://snaps.php.net/. Thank you for the report, and for helping us make PHP better. Previous Comments: ------------------------------------------------------------------------ [2006-11-25 14:35:46] wharmby at uk dot ibm dot com Sorry uploaded wrong version of patch above. Here is correct patch: http://pastebin.ca/257571 ------------------------------------------------------------------------ [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

« previous php.bugs (#105449) next »