tony2001 Tue Mar 6 19:59:13 2007 UTC
Modified files:
/php-src/ext/standard basic_functions.c
/php-src/ext/standard/tests/general_functions import_request.phpt
Log:
fix segfault in import_request_variables() and its test
I'm not completely sure it's correct to import numeric vars like _POST["1"]
etc.
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.850&r2=1.851&diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.850
php-src/ext/standard/basic_functions.c:1.851
--- php-src/ext/standard/basic_functions.c:1.850 Sat Mar 3 20:41:12 2007
+++ php-src/ext/standard/basic_functions.c Tue Mar 6 19:59:13 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: basic_functions.c,v 1.850 2007/03/03 20:41:12 helly Exp $ */
+/* $Id: basic_functions.c,v 1.851 2007/03/06 19:59:13 tony2001 Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -6363,9 +6363,15 @@
return;
}
- convert_to_text(prefix);
- if (Z_UNILEN_P(prefix) == 0) {
- php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No prefix specified
- possible security hazard");
+ if (ZEND_NUM_ARGS() > 1) {
+ convert_to_text(prefix);
+
+ if (Z_UNILEN_P(prefix) == 0) {
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "No prefix
specified - possible security hazard");
+ }
+ } else {
+ MAKE_STD_ZVAL(prefix);
+ ZVAL_EMPTY_TEXT(prefix);
}
for (p = types; p && *p; p++) {
@@ -6388,6 +6394,10 @@
break;
}
}
+
+ if (ZEND_NUM_ARGS() < 2) {
+ zval_ptr_dtor(&prefix);
+ }
}
/* }}} */
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/general_functions/import_request.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/general_functions/import_request.phpt
diff -u php-src/ext/standard/tests/general_functions/import_request.phpt:1.1
php-src/ext/standard/tests/general_functions/import_request.phpt:1.2
--- php-src/ext/standard/tests/general_functions/import_request.phpt:1.1
Thu Nov 16 13:00:03 2006
+++ php-src/ext/standard/tests/general_functions/import_request.phpt Tue Mar
6 19:59:13 2007
@@ -26,10 +26,8 @@
echo "Done\n";
?>
--EXPECTF--
-Warning: Wrong parameter count for import_request_variables() in %s on line %d
+Warning: import_request_variables() expects at least 1 parameter, 0 given in
%s on line %d
NULL
-
-Notice: import_request_variables(): No prefix specified - possible security
hazard in %s on line %d
NULL
Notice: import_request_variables(): No prefix specified - possible security
hazard in %s on line %d
@@ -37,9 +35,9 @@
Notice: import_request_variables(): No prefix specified - possible security
hazard in %s on line %d
-Warning: import_request_variables(): Attempted GLOBALS variable overwrite. in
%s on line %d
+Warning: import_request_variables(): Attempted GLOBALS variable overwrite in
%s on line %d
-Warning: import_request_variables(): Numeric key detected - possible security
hazard. in %s on line %d
+Warning: import_request_variables(): Numeric key detected - possible security
hazard in %s on line %d
NULL
Notice: Undefined variable: ap in %s on line %d
@@ -50,13 +48,11 @@
NULL
Notice: Undefined variable: g_ap in %s on line %d
-
-Notice: Undefined variable: g_1 in %s on line %d
string(1) "1"
string(3) "heh"
string(1) "3"
NULL
-NULL
+string(2) "hm"
NULL
string(1) "1"
string(3) "heh"
@@ -76,3 +72,50 @@
string(1) "3"
NULL
Done
+--UEXPECTF--
+Warning: import_request_variables() expects at least 1 parameter, 0 given in
%s on line %d
+NULL
+NULL
+
+Notice: import_request_variables(): No prefix specified - possible security
hazard in %s on line %d
+NULL
+
+Notice: import_request_variables(): No prefix specified - possible security
hazard in %s on line %d
+
+Warning: import_request_variables(): Attempted GLOBALS variable overwrite in
%s on line %d
+
+Warning: import_request_variables(): Numeric key detected - possible security
hazard in %s on line %d
+NULL
+
+Notice: Undefined variable: ap in %s on line %d
+unicode(1) "1"
+unicode(3) "heh"
+unicode(1) "3"
+NULL
+NULL
+
+Notice: Undefined variable: g_ap in %s on line %d
+unicode(1) "1"
+unicode(3) "heh"
+unicode(1) "3"
+NULL
+unicode(2) "hm"
+NULL
+unicode(1) "1"
+unicode(3) "heh"
+unicode(1) "3"
+unicode(2) "25"
+unicode(4) "test"
+unicode(5) "blah3"
+array(1) {
+ [0]=>
+ unicode(2) "ar"
+}
+NULL
+
+Notice: Undefined variable: r_ap in %s on line %d
+unicode(1) "1"
+unicode(3) "heh"
+unicode(1) "3"
+NULL
+Done
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php