#40098 [Asn->Csd]: php_fopen_primary_script() not thread safe
| From: | iliaa@php.net | Date: | Fri, 12 Jan 2007 01:46:21 +0000 |
| Subject: | #40098 [Asn->Csd]: php_fopen_primary_script() not thread safe | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-107513@lists.php.net to get a copy of this message | ||
ID: 40098
Updated by: iliaa@php.net
Reported By: wharmby at uk dot ibm dot com
-Status: Assigned
+Status: Closed
Bug Type: Streams related
Operating System: Linux RHEL4
PHP Version: 5CVS-2007-01-11 (snap)
Assigned To: iliaa
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:
------------------------------------------------------------------------
[2007-01-11 11:59:44] wharmby at uk dot ibm dot com
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 this bug report at http://bugs.php.net/?id=40098&edit=1