summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRasmus Lerdorf <rasmus@php.net>2001-08-13 06:43:47 +0000
committerRasmus Lerdorf <rasmus@php.net>2001-08-13 06:43:47 +0000
commit8c497f05c4d93f4054f67fb9875f0894364020e2 (patch)
tree0c3a97abb0de616fb036f38e18f752e042b36623
parent3f505f8624836b32f919b9fbcc533b8e069a87c9 (diff)
downloadphp-git-8c497f05c4d93f4054f67fb9875f0894364020e2.tar.gz
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.
-rw-r--r--ext/curl/curl.c3
-rw-r--r--ext/db/db.c3
-rw-r--r--ext/domxml/php_domxml.c3
-rw-r--r--ext/fdf/fdf.c3
-rw-r--r--ext/gd/gd.c3
-rw-r--r--ext/hyperwave/hw.c3
-rw-r--r--ext/interbase/interbase.c3
-rw-r--r--ext/mhash/mhash.c3
-rw-r--r--ext/odbc/php_odbc.c5
-rw-r--r--ext/sablot/sablot.c10
-rw-r--r--ext/session/session.c7
-rw-r--r--ext/snmp/snmp.c15
-rw-r--r--ext/sockets/sockets.c3
-rw-r--r--ext/standard/basic_functions.c3
-rw-r--r--ext/standard/info.c68
15 files changed, 91 insertions, 44 deletions
diff --git a/ext/curl/curl.c b/ext/curl/curl.c
index 717f970960..21c2641111 100644
--- a/ext/curl/curl.c
+++ b/ext/curl/curl.c
@@ -504,6 +504,9 @@ static void curl_free_slist(void **slist)
Return the CURL version string. */
PHP_FUNCTION(curl_version)
{
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
+ return;
+
RETURN_STRING(curl_version(), 1);
}
/* }}} */
diff --git a/ext/db/db.c b/ext/db/db.c
index 4ef741738f..cf0712da71 100644
--- a/ext/db/db.c
+++ b/ext/db/db.c
@@ -252,6 +252,9 @@ PHP_MINFO_FUNCTION(db)
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);
}
diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c
index aa63840417..d1a3042a11 100644
--- a/ext/domxml/php_domxml.c
+++ b/ext/domxml/php_domxml.c
@@ -2432,6 +2432,9 @@ PHP_FUNCTION(xmltree)
Initializing XPath environment */
PHP_FUNCTION(xpath_init)
{
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
+ return;
+
xmlXPathInit();
RETURN_TRUE;
}
diff --git a/ext/fdf/fdf.c b/ext/fdf/fdf.c
index a1b880a46c..f09b7433da 100644
--- a/ext/fdf/fdf.c
+++ b/ext/fdf/fdf.c
@@ -209,6 +209,9 @@ PHP_FUNCTION(fdf_create)
FDFDoc fdf;
FDFErc err;
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
+ return;
+
err = FDFCreate(&fdf);
if(err != FDFErcOK || !fdf) {
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index f7e781ef3e..e00f3c26e7 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -931,6 +931,9 @@ PHP_FUNCTION(imagetypes)
#ifdef HAVE_GD_XPM
ret |= 16;
#endif
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
+ return;
+
RETURN_LONG(ret);
}
/* }}} */
diff --git a/ext/hyperwave/hw.c b/ext/hyperwave/hw.c
index 8f3120e858..a00e1c7fa3 100644
--- a/ext/hyperwave/hw.c
+++ b/ext/hyperwave/hw.c
@@ -1331,6 +1331,9 @@ PHP_FUNCTION(hw_errormsg)
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;
}
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
index 273520c58f..0ed2c2412a 100644
--- a/ext/interbase/interbase.c
+++ b/ext/interbase/interbase.c
@@ -236,6 +236,9 @@ typedef struct {
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);
}
diff --git a/ext/mhash/mhash.c b/ext/mhash/mhash.c
index e630b7c392..d6ad84c7cf 100644
--- a/ext/mhash/mhash.c
+++ b/ext/mhash/mhash.c
@@ -83,6 +83,9 @@ static PHP_MINIT_FUNCTION(mhash)
Gets the number of available hashes */
PHP_FUNCTION(mhash_count)
{
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
+ return;
+
RETURN_LONG(mhash_count());
}
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index ab0638ed10..951e35a161 100644
--- a/ext/odbc/php_odbc.c
+++ b/ext/odbc/php_odbc.c
@@ -710,7 +710,10 @@ PHP_FUNCTION(odbc_close_all)
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 */
diff --git a/ext/sablot/sablot.c b/ext/sablot/sablot.c
index d5b7e031df..3d1a73609f 100644
--- a/ext/sablot/sablot.c
+++ b/ext/sablot/sablot.c
@@ -291,7 +291,10 @@ PHP_FUNCTION(xslt_output_endtransform)
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_FUNCTION(xslt_create)
php_sablot *handle;
SablotHandle p;
int ret;
-
+
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "") == FAILURE)
+ return;
+
ret = SablotCreateProcessor(&p);
if (ret) {
diff --git a/ext/session/session.c b/ext/session/session.c
index 1372c0b5cf..7ed6ad84d9 100644
--- a/ext/session/session.c
+++ b/ext/session/session.c
@@ -1229,6 +1229,9 @@ PHP_FUNCTION(session_encode)
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 @@ PHP_FUNCTION(session_decode)
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 @@ PHP_FUNCTION(session_start)
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 {
diff --git a/ext/snmp/snmp.c b/ext/snmp/snmp.c
index 6b635b196a..56c87e4dc4 100644
--- a/ext/snmp/snmp.c
+++ b/ext/snmp/snmp.c
@@ -402,6 +402,9 @@ PHP_FUNCTION(snmprealwalk)
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 @@ PHP_FUNCTION(snmp_get_quick_print)
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);
}
/* }}} */
diff --git a/ext/sockets/sockets.c b/ext/sockets/sockets.c
index 8e18d28697..d8629f0b42 100644
--- a/ext/sockets/sockets.c
+++ b/ext/sockets/sockets.c
@@ -397,6 +397,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));
FD_ZERO(&(php_fd->set));
diff --git a/ext/standard/basic_functions.c b/ext/standard/basic_functions.c
index 5501934dee..17b093bf59 100644
--- a/ext/standard/basic_functions.c
+++ b/ext/standard/basic_functions.c
@@ -1316,6 +1316,9 @@ PHP_FUNCTION(settype)
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);
}
/* }}} */
diff --git a/ext/standard/info.c b/ext/standard/info.c
index 27fa7d4edb..a1f50d9604 100644
--- a/ext/standard/info.c
+++ b/ext/standard/info.c
@@ -455,26 +455,16 @@ void register_phpinfo_constants(INIT_FUNC_ARGS)
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 @@ PHP_FUNCTION(phpinfo)
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 @@ PHP_FUNCTION(phpversion)
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 @@ PHP_FUNCTION(php_logo_guid)
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 @@ PHP_FUNCTION(php_egg_logo_guid)
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 @@ PHP_FUNCTION(zend_logo_guid)
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 @@ PHP_FUNCTION(php_sapi_name)
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);
}