jani            Wed Nov 21 11:28:26 2007 UTC

  Modified files:              
    /php-src/ext/standard       filestat.c 
  Log:
  - Fix crash when chown() 2nd parameter is something else than integer or 
string
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?r1=1.169&r2=1.170&diff_format=u
Index: php-src/ext/standard/filestat.c
diff -u php-src/ext/standard/filestat.c:1.169 
php-src/ext/standard/filestat.c:1.170
--- php-src/ext/standard/filestat.c:1.169       Mon Nov 19 15:55:48 2007
+++ php-src/ext/standard/filestat.c     Wed Nov 21 11:28:26 2007
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: filestat.c,v 1.169 2007/11/19 15:55:48 dmitry Exp $ */
+/* $Id: filestat.c,v 1.170 2007/11/21 11:28:26 jani Exp $ */
 
 #include "php.h"
 #include "fopen_wrappers.h"
@@ -434,7 +434,8 @@
        if (Z_TYPE_P(group) == IS_LONG) {
                gid = (gid_t)Z_LVAL_P(group);
        } else if (Z_TYPE_P(group) == IS_STRING ||
-                  Z_TYPE_P(group) == IS_UNICODE) {
+                  Z_TYPE_P(group) == IS_UNICODE
+       ) {
                if (Z_TYPE_P(group) == IS_UNICODE) {
                        zval_unicode_to_string(group TSRMLS_CC);
                }
@@ -466,7 +467,7 @@
                gid = gr->gr_gid;
 #endif
        } else {
-               php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 2 should 
be string or integer, %s given",zend_zval_type_name(group));
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 2 should 
be string or integer, %s given", zend_zval_type_name(group));
                RETURN_FALSE;
        }
 
@@ -548,8 +549,13 @@
        }
 
        if (Z_TYPE_P(user) == IS_LONG) {
-               uid = (uid_t)Z_LVAL_P(user);
-       } else {
+               uid = (uid_t) Z_LVAL_P(user);
+       } else if (Z_TYPE_P(user) == IS_STRING ||
+                  Z_TYPE_P(user) == IS_UNICODE
+       ) {
+               if (Z_TYPE_P(user) == IS_UNICODE) {
+                       zval_unicode_to_string(user TSRMLS_CC);
+               }
 #if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
                struct passwd pw;
                struct passwd *retpwptr = NULL;
@@ -577,6 +583,9 @@
                }
                uid = pw->pw_uid;
 #endif
+       } else {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "parameter 2 should 
be string or integer, %s given", zend_zval_type_name(user));
+               RETURN_FALSE;
        }
 
        if (filename_type == IS_UNICODE) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to