mirror of
https://github.com/php/php-src.git
synced 2025-08-21 01:45:16 +02:00
- Fix crash when chown() 2nd parameter is something else than integer or string
This commit is contained in:
parent
c1c404efc0
commit
ba1e024895
1 changed files with 13 additions and 4 deletions
|
@ -434,7 +434,8 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
|
||||||
if (Z_TYPE_P(group) == IS_LONG) {
|
if (Z_TYPE_P(group) == IS_LONG) {
|
||||||
gid = (gid_t)Z_LVAL_P(group);
|
gid = (gid_t)Z_LVAL_P(group);
|
||||||
} else if (Z_TYPE_P(group) == IS_STRING ||
|
} 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) {
|
if (Z_TYPE_P(group) == IS_UNICODE) {
|
||||||
zval_unicode_to_string(group TSRMLS_CC);
|
zval_unicode_to_string(group TSRMLS_CC);
|
||||||
}
|
}
|
||||||
|
@ -466,7 +467,7 @@ static void php_do_chgrp(INTERNAL_FUNCTION_PARAMETERS, int do_lchgrp) /* {{{ */
|
||||||
gid = gr->gr_gid;
|
gid = gr->gr_gid;
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} 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;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -548,8 +549,13 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Z_TYPE_P(user) == IS_LONG) {
|
if (Z_TYPE_P(user) == IS_LONG) {
|
||||||
uid = (uid_t)Z_LVAL_P(user);
|
uid = (uid_t) Z_LVAL_P(user);
|
||||||
} else {
|
} 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)
|
#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
|
||||||
struct passwd pw;
|
struct passwd pw;
|
||||||
struct passwd *retpwptr = NULL;
|
struct passwd *retpwptr = NULL;
|
||||||
|
@ -577,6 +583,9 @@ static void php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */
|
||||||
}
|
}
|
||||||
uid = pw->pw_uid;
|
uid = pw->pw_uid;
|
||||||
#endif
|
#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) {
|
if (filename_type == IS_UNICODE) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue