cvs: php4 /ext/curl curl.c /ext/db db.c /ext/domxml php_domxml.c /ext/fdf fdf.c /ext/gd gd.c /ext/hyperwave hw.c /ext/interbase interbase.c
/ext/mhash mhash.c /ext/odbc php_odbc.c /ext/sablot sablot.c /ext/session session.c /ext/snmp snmp.c /ext/sockets sockets.c /ext/standard
basic_functions.c info.c

From: Date: Mon, 13 Aug 2001 06:43:48 +0000
Subject: cvs: php4 /ext/curl curl.c /ext/db db.c /ext/domxml php_domxml.c /ext/fdf fdf.c /ext/gd gd.c /ext/hyperwave hw.c /ext/interbase interbase.c
/ext/mhash mhash.c /ext/odbc php_odbc.c /ext/sablot sablot.c /ext/session session.c /ext/snmp snmp.c /ext/sockets sockets.c /ext/standard
basic_functions.c info.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-6766@lists.php.net to get a copy of this message
rasmus Mon Aug 13 02:43:48 2001 EDT Modified files: /php4/ext/curl curl.c /php4/ext/db db.c /php4/ext/domxml php_domxml.c /php4/ext/fdf fdf.c /php4/ext/gd gd.c /php4/ext/hyperwave hw.c /php4/ext/interbase interbase.c /php4/ext/mhash mhash.c /php4/ext/odbc php_odbc.c /php4/ext/sablot sablot.c /php4/ext/session session.c /php4/ext/snmp snmp.c /php4/ext/sockets sockets.c /php4/ext/standard basic_functions.c info.c Log: We don't consistently check for args passed to functions that don't take any args. In some cases we probably want to skip the check for performance reasons, but in other cases where performance is unlikely to be a factor, not throwing a warning on the wrong number of args passed to a function is at best inconsistent, and at worst it could hide a bug. So, add a few such checks. There are still lots of cases out there.

Index: php4/ext/curl/curl.c diff -u php4/ext/curl/curl.c:1.77 php4/ext/curl/curl.c:1.78 --- php4/ext/curl/curl.c:1.77 Thu Aug 2 15:28:33 2001 +++ php4/ext/curl/curl.c Mon Aug 13 02:43:42 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: curl.c,v 1.77 2001/08/02 19:28:33 sterling Exp $ */ +/* $Id: curl.c,v 1.78 2001/08/13 06:43:42 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -504,6 +504,9 @@ Return the CURL version string. */ PHP_FUNCTION(curl_version) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRING(curl_version(), 1); } /* }}} */ Index: php4/ext/db/db.c diff -u php4/ext/db/db.c:1.61 php4/ext/db/db.c:1.62 --- php4/ext/db/db.c:1.61 Sat Aug 11 12:38:22 2001 +++ php4/ext/db/db.c Mon Aug 13 02:43:42 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: db.c,v 1.61 2001/08/11 16:38:22 zeev Exp $ */ +/* $Id: db.c,v 1.62 2001/08/13 06:43:42 rasmus Exp $ */ #define IS_EXT_MODULE #if 1 @@ -252,6 +252,9 @@ Describes the dbm-compatible library being used */ PHP_FUNCTION(dblist) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + char *str = php_get_info_db(); RETURN_STRING(str, 1); } Index: php4/ext/domxml/php_domxml.c diff -u php4/ext/domxml/php_domxml.c:1.55 php4/ext/domxml/php_domxml.c:1.56 --- php4/ext/domxml/php_domxml.c:1.55 Sat Aug 11 16:44:30 2001 +++ php4/ext/domxml/php_domxml.c Mon Aug 13 02:43:42 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_domxml.c,v 1.55 2001/08/11 20:44:30 joey Exp $ */ +/* $Id: php_domxml.c,v 1.56 2001/08/13 06:43:42 rasmus Exp $ */ #ifdef HAVE_CONFIG_H @@ -2432,6 +2432,9 @@ Initializing XPath environment */ PHP_FUNCTION(xpath_init) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + xmlXPathInit(); RETURN_TRUE; } Index: php4/ext/fdf/fdf.c diff -u php4/ext/fdf/fdf.c:1.57 php4/ext/fdf/fdf.c:1.58 --- php4/ext/fdf/fdf.c:1.57 Sat Aug 11 12:38:26 2001 +++ php4/ext/fdf/fdf.c Mon Aug 13 02:43:42 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: fdf.c,v 1.57 2001/08/11 16:38:26 zeev Exp $ */ +/* $Id: fdf.c,v 1.58 2001/08/13 06:43:42 rasmus Exp $ */ /* FdfTk lib 2.0 is a Complete C/C++ FDF Toolkit available from http://beta1.adobe.com/ada/acrosdk/forms.html. */ @@ -208,6 +208,9 @@ { FDFDoc fdf; FDFErc err; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; err = FDFCreate(&fdf); Index: php4/ext/gd/gd.c diff -u php4/ext/gd/gd.c:1.152 php4/ext/gd/gd.c:1.153 --- php4/ext/gd/gd.c:1.152 Sat Aug 11 12:38:28 2001 +++ php4/ext/gd/gd.c Mon Aug 13 02:43:43 2001 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: gd.c,v 1.152 2001/08/11 16:38:28 zeev Exp $ */ +/* $Id: gd.c,v 1.153 2001/08/13 06:43:43 rasmus Exp $ */ /* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center, Cold Spring Harbor Labs. */ @@ -931,6 +931,9 @@ #ifdef HAVE_GD_XPM ret |= 16; #endif + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_LONG(ret); } /* }}} */ Index: php4/ext/hyperwave/hw.c diff -u php4/ext/hyperwave/hw.c:1.92 php4/ext/hyperwave/hw.c:1.93 --- php4/ext/hyperwave/hw.c:1.92 Sat Aug 11 12:38:40 2001 +++ php4/ext/hyperwave/hw.c Mon Aug 13 02:43:43 2001 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: hw.c,v 1.92 2001/08/11 16:38:40 zeev Exp $ */ +/* $Id: hw.c,v 1.93 2001/08/13 06:43:43 rasmus Exp $ */ #include <stdlib.h> #include <errno.h> @@ -1331,6 +1331,9 @@ Returns object id of root collection */ PHP_FUNCTION(hw_root) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + return_value->value.lval = 0; return_value->type = IS_LONG; } Index: php4/ext/interbase/interbase.c diff -u php4/ext/interbase/interbase.c:1.66 php4/ext/interbase/interbase.c:1.67 --- php4/ext/interbase/interbase.c:1.66 Sat Aug 11 12:38:57 2001 +++ php4/ext/interbase/interbase.c Mon Aug 13 02:43:43 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: interbase.c,v 1.66 2001/08/11 16:38:57 zeev Exp $ */ +/* $Id: interbase.c,v 1.67 2001/08/13 06:43:43 rasmus Exp $ */ /* TODO: Arrays, roles? @@ -236,6 +236,9 @@ Return error message */ PHP_FUNCTION(ibase_errmsg) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + if (IBG(errmsg[0])) { RETURN_STRING(IBG(errmsg), 1); } @@ -577,7 +580,7 @@ php_info_print_table_start(); php_info_print_table_row(2, "Interbase Support", "enabled"); - php_info_print_table_row(2, "Revision", "$Revision: 1.66 $"); + php_info_print_table_row(2, "Revision", "$Revision: 1.67 $"); #ifdef COMPILE_DL_INTERBASE php_info_print_table_row(2, "Dynamic Module", "yes"); #endif Index: php4/ext/mhash/mhash.c diff -u php4/ext/mhash/mhash.c:1.30 php4/ext/mhash/mhash.c:1.31 --- php4/ext/mhash/mhash.c:1.30 Fri Jul 27 06:16:22 2001 +++ php4/ext/mhash/mhash.c Mon Aug 13 02:43:44 2001 @@ -83,6 +83,9 @@ Gets the number of available hashes */ PHP_FUNCTION(mhash_count) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_LONG(mhash_count()); } Index: php4/ext/odbc/php_odbc.c diff -u php4/ext/odbc/php_odbc.c:1.104 php4/ext/odbc/php_odbc.c:1.105 --- php4/ext/odbc/php_odbc.c:1.104 Sat Aug 11 14:28:31 2001 +++ php4/ext/odbc/php_odbc.c Mon Aug 13 02:43:44 2001 @@ -20,7 +20,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_odbc.c,v 1.104 2001/08/11 18:28:31 andi Exp $ */ +/* $Id: php_odbc.c,v 1.105 2001/08/13 06:43:44 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -710,7 +710,10 @@ int type; int i; int nument; - + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + nument = zend_hash_next_free_element(&EG(regular_list)); /* Loop through list and close all statements */ Index: php4/ext/sablot/sablot.c diff -u php4/ext/sablot/sablot.c:1.51 php4/ext/sablot/sablot.c:1.52 --- php4/ext/sablot/sablot.c:1.51 Fri Aug 10 09:04:58 2001 +++ php4/ext/sablot/sablot.c Mon Aug 13 02:43:45 2001 @@ -291,7 +291,10 @@ char *tRes = NULL, *buffer = NULL; int ret = 0; - + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + /** * Make sure that we don't have more than one output buffer going on * at the same time. @@ -556,7 +559,10 @@ php_sablot *handle; SablotHandle p; int ret; - + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + ret = SablotCreateProcessor(&p); if (ret) { Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.235 php4/ext/session/session.c:1.236 --- php4/ext/session/session.c:1.235 Sat Aug 11 06:49:03 2001 +++ php4/ext/session/session.c Mon Aug 13 02:43:45 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c,v 1.235 2001/08/11 10:49:03 sniper Exp $ */ +/* $Id: session.c,v 1.236 2001/08/13 06:43:45 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1229,6 +1229,9 @@ int len; char *enc; + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + enc = php_session_encode(&len TSRMLS_CC); RETVAL_STRINGL(enc, len, 0); } @@ -1253,6 +1256,7 @@ Begin session - reinitializes freezed variables, registers browsers etc */ PHP_FUNCTION(session_start) { + /* skipping check for non-zero args for performance reasons here ?*/ php_session_start(TSRMLS_C); RETURN_TRUE; } @@ -1262,6 +1266,9 @@ Destroy the current session and all data associated with it */ PHP_FUNCTION(session_destroy) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + if (php_session_destroy(TSRMLS_C) == SUCCESS) { RETURN_TRUE; } else { Index: php4/ext/snmp/snmp.c diff -u php4/ext/snmp/snmp.c:1.45 php4/ext/snmp/snmp.c:1.46 --- php4/ext/snmp/snmp.c:1.45 Sat Aug 4 21:42:40 2001 +++ php4/ext/snmp/snmp.c Mon Aug 13 02:43:46 2001 @@ -17,7 +17,7 @@ | Steven Lawrance <slawrance@technologist.com> | +----------------------------------------------------------------------+ */ -/* $Id: snmp.c,v 1.45 2001/08/05 01:42:40 zeev Exp $ */ +/* $Id: snmp.c,v 1.46 2001/08/13 06:43:46 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -402,6 +402,9 @@ Return the current status of quick_print */ PHP_FUNCTION(snmp_get_quick_print) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_LONG(snmp_get_quick_print() ? 1 : 0); } /* }}} */ @@ -410,12 +413,12 @@ Return all objects including their respective object id withing the specified one */ PHP_FUNCTION(snmp_set_quick_print) { - zval **a1; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &a1) == FAILURE) { - WRONG_PARAM_COUNT; - } - convert_to_long_ex(a1); - snmp_set_quick_print((int)(*a1)->value.lval); + int argc = ZEND_NUM_ARGS(); + long a1; + + if (zend_parse_parameters(argc, "l", &a1) == FAILURE) + return; + snmp_set_quick_print((int)a1); } /* }}} */ Index: php4/ext/sockets/sockets.c diff -u php4/ext/sockets/sockets.c:1.59 php4/ext/sockets/sockets.c:1.60 --- php4/ext/sockets/sockets.c:1.59 Tue Jul 31 01:44:05 2001 +++ php4/ext/sockets/sockets.c Mon Aug 13 02:43:46 2001 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: sockets.c,v 1.59 2001/07/31 05:44:05 zeev Exp $ */ +/* $Id: sockets.c,v 1.60 2001/08/13 06:43:46 rasmus Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -396,6 +396,9 @@ PHP_FUNCTION(socket_fd_alloc) { php_fd_set *php_fd; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; php_fd = (php_fd_set*)emalloc(sizeof(php_fd_set)); Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.383 php4/ext/standard/basic_functions.c:1.384 --- php4/ext/standard/basic_functions.c:1.383 Sun Aug 12 20:32:03 2001 +++ php4/ext/standard/basic_functions.c Mon Aug 13 02:43:47 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.383 2001/08/13 00:32:03 zeev Exp $ */ +/* $Id: basic_functions.c,v 1.384 2001/08/13 06:43:47 rasmus Exp $ */ #include "php.h" #include "php_main.h" @@ -1316,6 +1316,9 @@ Get the name of the owner of the current PHP script */ PHP_FUNCTION(get_current_user) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRING(php_get_current_user(), 1); } /* }}} */ Index: php4/ext/standard/info.c diff -u php4/ext/standard/info.c:1.149 php4/ext/standard/info.c:1.150 --- php4/ext/standard/info.c:1.149 Sat Aug 11 13:03:37 2001 +++ php4/ext/standard/info.c Mon Aug 13 02:43:47 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: info.c,v 1.149 2001/08/11 17:03:37 zeev Exp $ */ +/* $Id: info.c,v 1.150 2001/08/13 06:43:47 rasmus Exp $ */ #include "php.h" #include "php_ini.h" @@ -455,26 +455,16 @@ Output a page of useful information about PHP and the current request */ PHP_FUNCTION(phpinfo) { - int flag; - zval **flag_arg; + int argc = ZEND_NUM_ARGS(); + long flag; + if (zend_parse_parameters(argc, "|l", &flag) == FAILURE) + return; - switch (ZEND_NUM_ARGS()) { - case 0: - flag = 0xFFFFFFFF; - break; - case 1: - if (zend_get_parameters_ex(1, &flag_arg)==FAILURE) { - RETURN_FALSE; - } - convert_to_long_ex(flag_arg); - flag = (*flag_arg)->value.lval; - break; - default: - WRONG_PARAM_COUNT; - break; + if(!argc) { + flag = 0xFFFFFFFF; } - php_print_info(flag TSRMLS_CC); + RETURN_TRUE; } @@ -484,6 +474,9 @@ Return the current PHP version */ PHP_FUNCTION(phpversion) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRING(PHP_VERSION, 1); } /* }}} */ @@ -492,35 +485,28 @@ Prints the list of people who've contributed to the PHP project */ PHP_FUNCTION(phpcredits) { - int flag; - zval **flag_arg; + int argc = ZEND_NUM_ARGS(); + long flag; + if (zend_parse_parameters(argc, "|l", &flag) == FAILURE) + return; + + if(!argc) { + flag = 0xFFFFFFFF; + } - switch (ZEND_NUM_ARGS()) { - case 0: - flag = 0xFFFFFFFF; - break; - case 1: - if (zend_get_parameters_ex(1, &flag_arg)==FAILURE) { - RETURN_FALSE; - } - convert_to_long_ex(flag_arg); - flag = (*flag_arg)->value.lval; - break; - default: - WRONG_PARAM_COUNT; - break; - } php_print_credits(flag); RETURN_TRUE; } - /* }}} */ /* {{{ proto string php_logo_guid(void) Return the special ID used to request the PHP logo in phpinfo screens*/ PHP_FUNCTION(php_logo_guid) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRINGL(PHP_LOGO_GUID, sizeof(PHP_LOGO_GUID)-1, 1); } /* }}} */ @@ -529,6 +515,9 @@ Return the special ID used to request the PHP logo in phpinfo screens*/ PHP_FUNCTION(php_egg_logo_guid) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRINGL(PHP_EGG_LOGO_GUID, sizeof(PHP_EGG_LOGO_GUID)-1, 1); } /* }}} */ @@ -537,6 +526,9 @@ Return the special ID used to request the Zend logo in phpinfo screens*/ PHP_FUNCTION(zend_logo_guid) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRINGL(ZEND_LOGO_GUID, sizeof(ZEND_LOGO_GUID)-1, 1); } /* }}} */ @@ -545,6 +537,9 @@ Return the current SAPI module name */ PHP_FUNCTION(php_sapi_name) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + if (sapi_module.name) { RETURN_STRING(sapi_module.name, 1); } else { @@ -558,6 +553,9 @@ Return information about the system PHP was built on */ PHP_FUNCTION(php_uname) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE) + return; + RETURN_STRING(php_get_uname(), 0); }
« previous php.cvs (#6766) next »