iliaa Wed Nov 29 23:34:49 2006 UTC Modified files: (Branch: PHP_5_2) /php-src/ext/standard filestat.c /php-src configure.in NEWS Log: Fixed bug #39648 (Implementation of PHP functions chown() and chgrp() are not thread safe). http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?r1=1.136.2.8.2.4&r2=1.136.2.8.2.5&diff_format=u Index: php-src/ext/standard/filestat.c diff -u php-src/ext/standard/filestat.c:1.136.2.8.2.4 php-src/ext/standard/filestat.c:1.136.2.8.2.5 --- php-src/ext/standard/filestat.c:1.136.2.8.2.4 Mon Nov 6 14:54:52 2006 +++ php-src/ext/standard/filestat.c Wed Nov 29 23:34:49 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: filestat.c,v 1.136.2.8.2.4 2006/11/06 14:54:52 dmitry Exp $ */ +/* $Id: filestat.c,v 1.136.2.8.2.5 2006/11/29 23:34:49 iliaa Exp $ */ #include "php.h" #include "safe_mode.h" @@ -356,7 +356,6 @@ { zval **filename, **group; gid_t gid; - struct group *gr=NULL; int ret; if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &filename, &group)==FAILURE) { @@ -364,13 +363,28 @@ } convert_to_string_ex(filename); if (Z_TYPE_PP(group) == IS_STRING) { - gr = getgrnam(Z_STRVAL_PP(group)); +#if HAVE_GETGRNAM_R + struct group gr; + struct group *retgrptr; + int grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX); + char *grbuf = emalloc(grbuflen); + + if (getgrnam_r(Z_STRVAL_PP(group), &gr, grbuf, grbuflen, &retgrptr) != 0 || retgrptr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s", Z_STRVAL_PP(group)); + efree(grbuf); + RETURN_FALSE; + } + efree(grbuf); + gid = gr.gr_gid; +#else + struct group *gr = getgrnam(Z_STRVAL_PP(group)); + if (!gr) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s", - Z_STRVAL_PP(group)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find gid for %s", Z_STRVAL_PP(group)); RETURN_FALSE; } gid = gr->gr_gid; +#endif } else { convert_to_long_ex(group); gid = Z_LVAL_PP(group); @@ -434,20 +448,34 @@ zval **filename, **user; int ret; uid_t uid; - struct passwd *pw = NULL; if (ZEND_NUM_ARGS()!=2 || zend_get_parameters_ex(2, &filename, &user)==FAILURE) { WRONG_PARAM_COUNT; } convert_to_string_ex(filename); if (Z_TYPE_PP(user) == IS_STRING) { - pw = getpwnam(Z_STRVAL_PP(user)); +#ifdef HAVE_GETPWNAM_R + struct passwd pw; + struct passwd *retpwptr = NULL; + int pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX); + char *pwbuf = emalloc(pwbuflen); + + if (getpwnam_r(Z_STRVAL_PP(user), &pw, pwbuf, pwbuflen, &retpwptr) != 0 || retpwptr == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s", Z_STRVAL_PP(user)); + efree(pwbuf); + RETURN_FALSE; + } + efree(pwbuf); + uid = pw.pw_uid; +#else + struct passwd *pw = getpwnam(Z_STRVAL_PP(user)); + if (!pw) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s", - Z_STRVAL_PP(user)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to find uid for %s", Z_STRVAL_PP(user)); RETURN_FALSE; } uid = pw->pw_uid; +#endif } else { convert_to_long_ex(user); uid = Z_LVAL_PP(user); http://cvs.php.net/viewvc.cgi/php-src/configure.in?r1=1.579.2.52.2.25&r2=1.579.2.52.2.26&diff_format=u Index: php-src/configure.in diff -u php-src/configure.in:1.579.2.52.2.25 php-src/configure.in:1.579.2.52.2.26 --- php-src/configure.in:1.579.2.52.2.25 Mon Oct 30 23:08:30 2006 +++ php-src/configure.in Wed Nov 29 23:34:49 2006 @@ -1,4 +1,4 @@ - ## $Id: configure.in,v 1.579.2.52.2.25 2006/10/30 23:08:30 iliaa Exp $ -*- autoconf -*- + ## $Id: configure.in,v 1.579.2.52.2.26 2006/11/29 23:34:49 iliaa Exp $ -*- autoconf -*- dnl ## Process this file with autoconf to produce a configure script. divert(1) @@ -480,6 +480,8 @@ getrusage \ gettimeofday \ gmtime_r \ +getpwnam_r \ +getgrnam_r \ grantpt \ inet_ntoa \ inet_ntop \ http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.384&r2=1.2027.2.547.2.385&diff_format=u Index: php-src/NEWS diff -u php-src/NEWS:1.2027.2.547.2.384 php-src/NEWS:1.2027.2.547.2.385 --- php-src/NEWS:1.2027.2.547.2.384 Wed Nov 29 20:00:49 2006 +++ php-src/NEWS Wed Nov 29 23:34:49 2006 @@ -55,6 +55,8 @@ after closeCursor()). (Ilia, Tony) - Fixed bug #39653 (ext/dba doesn't check for db-4.5 and db-4.4 when db4 support is enabled). (Tony) +- Fixed bug #39648 (Implementation of PHP functions chown() and chgrp() are not + thread safe). (Ilia, wharmby at uk dot ibm dot com) - Fixed bug #39623 (thread safety fixes on *nix for putenv() & mime_magic). (Ilia, wharmby at uk dot ibm dot com) - Fixed bug #39621 (str_replace() is not binary safe on strings with equal
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php