From:             wharmby at uk dot ibm dot com
Operating system: Linux RHEL4
PHP version:      5CVS-2006-12-06 (snap)
PHP Bug Type:     Unknown/Other Function
Bug description:  Some POSIX extension functions not thread safe 

Description:
------------
The current implementation of the following POSIX extension
functions calls non-reentrant functions as follows:

   posix_ttynamee uses ttyname
   posix_getpwnam uses getpwnam
   posix_getgrnam uses getgrnam 

and therefore not thread safe. This will lead to unexpected 
behaviour when used in ZTS enabled builds. 

In all cases there are re-entrant versions of these functions available on
*nix systems, namely ttyname_r 
getpwnam_r and getgrnam_r which should be used instead in order to ensure
thread safety.

The following patch, which was built against the latest snapshot (Dec 6th,
2006, 1130 GMT) modifies the code in 
ext/posix/posix.c to use the reentrant versions of these 
functions:

    http://pastebin.ca/269334

The following patch makes the necessary modification to the 
configure.in file to support the above change:

    http://pastebin.ca/269335
        

Andy Wharmby
IBM United Kingdom Limited


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
as it stands.

Expected result:
----------------
N/A

Actual result:
--------------
N/A

-- 
Edit bug report at http://bugs.php.net/?id=39754&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39754&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39754&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39754&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39754&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39754&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39754&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39754&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39754&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39754&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39754&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39754&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39754&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39754&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39754&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39754&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39754&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39754&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39754&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39754&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39754&r=mysqlcfg

Reply via email to