cvs: php-src /ext/standard filestat.c /ext/standard/tests/file chgrp.phpt
| From: | Dmitry Stogov | Date: | Mon, 19 Nov 2007 15:55:48 +0000 |
| Subject: | cvs: php-src /ext/standard filestat.c /ext/standard/tests/file chgrp.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-47234@lists.php.net to get a copy of this message | ||
dmitry Mon Nov 19 15:55:48 2007 UTC
Modified files:
/php-src/ext/standard filestat.c
/php-src/ext/standard/tests/file chgrp.phpt
Log:
fixed SIGSEGV in chgrp()
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/filestat.c?r1=1.168&r2=1.169&diff_format=u
Index: php-src/ext/standard/filestat.c
diff -u php-src/ext/standard/filestat.c:1.168 php-src/ext/standard/filestat.c:1.169
--- php-src/ext/standard/filestat.c:1.168 Mon Nov 5 16:29:04 2007
+++ php-src/ext/standard/filestat.c Mon Nov 19 15:55:48 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: filestat.c,v 1.168 2007/11/05 16:29:04 jani Exp $ */
+/* $Id: filestat.c,v 1.169 2007/11/19 15:55:48 dmitry Exp $ */
#include "php.h"
#include "fopen_wrappers.h"
@@ -428,12 +428,16 @@
int ret;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "tz/", &filename,
&filename_len, &filename_type, &group) == FAILURE) {
- return;
+ RETURN_FALSE;
}
if (Z_TYPE_P(group) == IS_LONG) {
gid = (gid_t)Z_LVAL_P(group);
- } else {
+ } else if (Z_TYPE_P(group) == IS_STRING ||
+ Z_TYPE_P(group) == IS_UNICODE) {
+ if (Z_TYPE_P(group) == IS_UNICODE) {
+ zval_unicode_to_string(group TSRMLS_CC);
+ }
#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
struct group gr;
struct group *retgrptr;
@@ -461,6 +465,9 @@
}
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));
+ RETURN_FALSE;
}
if (filename_type == IS_UNICODE) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/file/chgrp.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/file/chgrp.phpt
diff -u php-src/ext/standard/tests/file/chgrp.phpt:1.1
php-src/ext/standard/tests/file/chgrp.phpt:1.2
--- php-src/ext/standard/tests/file/chgrp.phpt:1.1 Wed Nov 14 15:51:35 2007
+++ php-src/ext/standard/tests/file/chgrp.phpt Mon Nov 19 15:55:48 2007
@@ -5,5 +5,6 @@
chgrp("sjhgfskhagkfdgskjfhgskfsdgfkdsajf", NULL);
echo "ALIVE\n";
?>
---EXPECT--
+--EXPECTF--
+Warning: chgrp(): parameter 2 should be string or integer, null given in %schgrp.php on line 2
ALIVE