Closes GH-4878.
Bug #71221 (Null pointer deref (segfault) in get_defined_vars via ob_start)
--FILE--
<?php
-ob_start("get_defined_vars");
-try {
- ob_end_clean();
-} catch (\Error $e) {
- echo $e->getMessage();
-}
-?>
-
-OKAY
+register_shutdown_function("get_defined_vars");
--EXPECT--
-Cannot call get_defined_vars() dynamically
-OKAY
+Fatal error: Uncaught Error: Cannot call get_defined_vars() dynamically in [no active file]:0
+Stack trace:
+#0 [internal function]: get_defined_vars()
+#1 {main}
+ thrown in [no active file] on line 0
ZEND_FUNCTION(get_defined_vars)
{
zend_array *symbol_table;
+
+ ZEND_PARSE_PARAMETERS_NONE();
+
if (zend_forbid_dynamic_call("get_defined_vars()") == FAILURE) {
return;
}
#if ZEND_DEBUG && defined(ZTS)
ZEND_FUNCTION(zend_thread_id)
{
+ ZEND_PARSE_PARAMETERS_NONE();
+
RETURN_LONG((zend_long)tsrm_thread_id());
}
#endif
{
zval *referent;
- ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1,1)
+ ZEND_PARSE_PARAMETERS_START(1,1)
Z_PARAM_OBJECT(referent)
ZEND_PARSE_PARAMETERS_END();
ZEND_METHOD(WeakReference, get)
{
- ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 0)
- ZEND_PARSE_PARAMETERS_END();
+ ZEND_PARSE_PARAMETERS_NONE();
zend_weakref_get(getThis(), return_value);
}
php_date_obj *dateobj;
HashTable *myht;
+ ZEND_PARSE_PARAMETERS_NONE();
+
dateobj = Z_PHPDATE_P(object);
myht = Z_OBJPROP_P(object);
*/
PHP_FUNCTION(date_get_last_errors)
{
+ ZEND_PARSE_PARAMETERS_NONE();
+
if (DATEG(last_errors)) {
array_init(return_value);
zval_from_error_container(return_value, DATEG(last_errors));
php_timezone_obj *tzobj;
HashTable *myht;
+ ZEND_PARSE_PARAMETERS_NONE();
+
tzobj = Z_PHPTIMEZONE_P(object);
myht = Z_OBJPROP_P(object);
php_interval_obj *intobj;
HashTable *myht;
+ ZEND_PARSE_PARAMETERS_NONE();
+
intobj = Z_PHPINTERVAL_P(object);
myht = Z_OBJPROP_P(object);
dpobj->end = clone;
}
}
-
+
if (dpobj->end == NULL && recurrences < 1) {
php_error_docref(NULL, E_WARNING, "The recurrence count '%d' is invalid. Needs to be > 0", (int) recurrences);
}
{
const timelib_tzdb *tzdb;
+ ZEND_PARSE_PARAMETERS_NONE();
+
tzdb = DATE_TIMEZONEDB;
RETURN_STRING(tzdb->version);
}
const timelib_tz_lookup_table *table, *entry;
zval element, *abbr_array_p, abbr_array;
+ ZEND_PARSE_PARAMETERS_NONE();
+
table = timelib_timezone_abbreviations_list();
array_init(return_value);
entry = table;
php_period_obj *period_obj;
HashTable *myht;
+ ZEND_PARSE_PARAMETERS_NONE();
+
period_obj = Z_PHPPERIOD_P(object);
myht = Z_OBJPROP_P(object);
dom_object *intern;
char *value;
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern);
value = (char *) xmlGetNodePath(nodep);
*/
PHP_FUNCTION( intl_get_error_code )
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
RETURN_LONG( intl_error_get_code( NULL ) );
}
/* }}} */
*/
PHP_FUNCTION( intl_get_error_message )
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
RETURN_STR(intl_error_get_message( NULL ));
}
/* }}} */
UVersionInfo version;
int i;
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
u_getUnicodeVersion(version);
array_init(return_value);
Get MySQL client info */
PHP_FUNCTION(mysqli_get_client_info)
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
const char * info = mysql_get_client_info();
if (info) {
RETURN_STRING(info);
Get MySQL client info */
PHP_FUNCTION(mysqli_get_client_version)
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
RETURN_LONG((zend_long)mysql_get_client_version());
}
/* }}} */
MYSQLI_RESOURCE *mysqli_resource;
MY_MYSQL *mysql;
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
if (is_method && (Z_MYSQLI_P(getThis()))->ptr) {
return;
}
Return whether thread safety is given or not */
PHP_FUNCTION(mysqli_thread_safe)
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
RETURN_BOOL(mysql_thread_safe());
}
/* }}} */
Returns the numerical value of the error message from last connect command */
PHP_FUNCTION(mysqli_connect_errno)
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
RETURN_LONG(MyG(error_no));
}
/* }}} */
Returns the text of the error message from previous MySQL operation */
PHP_FUNCTION(mysqli_connect_error)
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
if (MyG(error_msg)) {
RETURN_STRING(MyG(error_msg));
} else {
Returns information about open and cached links */
PHP_FUNCTION(mysqli_get_links_stats)
{
- if (ZEND_NUM_ARGS()) {
- php_error_docref(NULL, E_WARNING, "no parameters expected");
+ if (zend_parse_parameters_none() == FAILURE) {
return;
}
+
array_init(return_value);
add_assoc_long_ex(return_value, "total", sizeof("total") - 1, MyG(num_links));
add_assoc_long_ex(return_value, "active_plinks", sizeof("active_plinks") - 1, MyG(num_active_persistent));
$link = NULL;
// too many parameter
- if (0 !== ($tmp = @mysqli_connect_errno($link)))
- printf("[001] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp);
+ try {
+ mysqli_connect_errno($link);
+ } catch (ArgumentCountError $exception) {
+ print($exception->getMessage() . "\n");
+ }
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
print "done!";
?>
--EXPECT--
+mysqli_connect_errno() expects exactly 0 parameters, 1 given
done!
$link = NULL;
// too many parameter
- if (!is_null($tmp = @mysqli_connect_error($link)))
- printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
+ try {
+ mysqli_connect_error($link);
+ } catch (ArgumentCountError $exception) {
+ print($exception->getMessage() . "\n");
+ }
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
print "done!";
?>
--EXPECT--
+mysqli_connect_error() expects exactly 0 parameters, 1 given
done!
mysqli_errno($plink), mysqli_error($plink));
}
- var_dump(mysqli_get_links_stats(1));
+ try {
+ mysqli_get_links_stats(1);
+ } catch (ArgumentCountError $exception) {
+ echo $exception->getMessage() . "\n";
+ }
echo "Before pconnect:";
var_dump(mysqli_get_links_stats());
mysqli_close($link);
?>
---EXPECTF--
-Warning: mysqli_get_links_stats(): no parameters expected in %s on line %d
-NULL
+--EXPECT--
+mysqli_get_links_stats() expects exactly 0 parameters, 1 given
Before pconnect:array(3) {
["total"]=>
int(1)
!mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT))
printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
- $tmp = mysqli_thread_safe($link);
$tmp = mysqli_thread_id($link);
mysqli_close($link);
size_t i;
size_t len = EC_get_builtin_curves(NULL, 0);
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
curves = emalloc(sizeof(EC_builtin_curve) * len);
if (!EC_get_builtin_curves(curves, len)) {
RETURN_FALSE;
{
PHP_STMT_GET_OBJ;
+ ZEND_PARSE_PARAMETERS_NONE();
+
RETURN_LONG(stmt->row_count);
}
/* }}} */
{
PHP_STMT_GET_OBJ;
+ ZEND_PARSE_PARAMETERS_NONE();
+
if (!stmt->methods->next_rowset) {
pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver does not support multiple rowsets");
RETURN_FALSE;
{
PHP_STMT_GET_OBJ;
+ ZEND_PARSE_PARAMETERS_NONE();
+
if (!stmt->methods->cursor_closer) {
/* emulate it by fetching and discarding rows */
do {
A utility for internals hackers to debug parameter internals */
static PHP_METHOD(PDOStatement, debugDumpParams)
{
+ ZEND_PARSE_PARAMETERS_NONE();
+
php_stream *out = php_stream_open_wrapper("php://output", "w", 0, NULL);
struct pdo_bound_param_data *param;
PHP_STMT_GET_OBJ;
pdo_pgsql_db_handle *H;
Oid lfd;
+ ZEND_PARSE_PARAMETERS_NONE();
+
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
PDO_DBH_CLEAR_ERR();
pdo_dbh_t *dbh;
pdo_pgsql_db_handle *H;
+ ZEND_PARSE_PARAMETERS_NONE();
+
dbh = Z_PDO_DBH_P(ZEND_THIS);
PDO_CONSTRUCT_CHECK;
{
php_shutdown_function_entry shutdown_function_entry;
+ ZEND_PARSE_PARAMETERS_NONE();
+
/* This function is registered itself as a shutdown function by
* session_set_save_handler($obj). The reason we now register another
* shutdown function is in case the user registered their own shutdown