Skip to content

Commit 6eaef4a

Browse files
committed
Add missing ZPP checks
1 parent 9493893 commit 6eaef4a

File tree

15 files changed

+101
-13
lines changed

15 files changed

+101
-13
lines changed

Zend/zend_builtin_functions.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,8 @@ ZEND_FUNCTION(get_defined_vars)
16251625
return;
16261626
}
16271627

1628+
ZEND_PARSE_PARAMETERS_NONE();
1629+
16281630
symbol_table = zend_rebuild_symbol_table();
16291631
if (UNEXPECTED(symbol_table == NULL)) {
16301632
return;
@@ -1637,6 +1639,8 @@ ZEND_FUNCTION(get_defined_vars)
16371639
#if ZEND_DEBUG && defined(ZTS)
16381640
ZEND_FUNCTION(zend_thread_id)
16391641
{
1642+
ZEND_PARSE_PARAMETERS_NONE();
1643+
16401644
RETURN_LONG((zend_long)tsrm_thread_id());
16411645
}
16421646
#endif

Zend/zend_weakrefs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ ZEND_METHOD(WeakReference, create)
158158
{
159159
zval *referent;
160160

161-
ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 1,1)
161+
ZEND_PARSE_PARAMETERS_START(1,1)
162162
Z_PARAM_OBJECT(referent)
163163
ZEND_PARSE_PARAMETERS_END();
164164

@@ -171,8 +171,7 @@ ZEND_METHOD(WeakReference, create)
171171

172172
ZEND_METHOD(WeakReference, get)
173173
{
174-
ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_THROW, 0, 0)
175-
ZEND_PARSE_PARAMETERS_END();
174+
ZEND_PARSE_PARAMETERS_NONE();
176175

177176
zend_weakref_get(getThis(), return_value);
178177
}

ext/date/php_date.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,8 @@ PHP_METHOD(DateTime, __wakeup)
26672667
php_date_obj *dateobj;
26682668
HashTable *myht;
26692669

2670+
ZEND_PARSE_PARAMETERS_NONE();
2671+
26702672
dateobj = Z_PHPDATE_P(object);
26712673

26722674
myht = Z_OBJPROP_P(object);
@@ -2703,6 +2705,8 @@ static void zval_from_error_container(zval *z, timelib_error_container *error) /
27032705
*/
27042706
PHP_FUNCTION(date_get_last_errors)
27052707
{
2708+
ZEND_PARSE_PARAMETERS_NONE();
2709+
27062710
if (DATEG(last_errors)) {
27072711
array_init(return_value);
27082712
zval_from_error_container(return_value, DATEG(last_errors));
@@ -3581,6 +3585,8 @@ PHP_METHOD(DateTimeZone, __wakeup)
35813585
php_timezone_obj *tzobj;
35823586
HashTable *myht;
35833587

3588+
ZEND_PARSE_PARAMETERS_NONE();
3589+
35843590
tzobj = Z_PHPTIMEZONE_P(object);
35853591

35863592
myht = Z_OBJPROP_P(object);
@@ -4064,6 +4070,8 @@ PHP_METHOD(DateInterval, __wakeup)
40644070
php_interval_obj *intobj;
40654071
HashTable *myht;
40664072

4073+
ZEND_PARSE_PARAMETERS_NONE();
4074+
40674075
intobj = Z_PHPINTERVAL_P(object);
40684076

40694077
myht = Z_OBJPROP_P(object);
@@ -4294,7 +4302,7 @@ PHP_METHOD(DatePeriod, __construct)
42944302
dpobj->end = clone;
42954303
}
42964304
}
4297-
4305+
42984306
if (dpobj->end == NULL && recurrences < 1) {
42994307
php_error_docref(NULL, E_WARNING, "The recurrence count '%d' is invalid. Needs to be > 0", (int) recurrences);
43004308
}
@@ -4467,6 +4475,8 @@ PHP_FUNCTION(timezone_version_get)
44674475
{
44684476
const timelib_tzdb *tzdb;
44694477

4478+
ZEND_PARSE_PARAMETERS_NONE();
4479+
44704480
tzdb = DATE_TIMEZONEDB;
44714481
RETURN_STRING(tzdb->version);
44724482
}
@@ -4480,6 +4490,8 @@ PHP_FUNCTION(timezone_abbreviations_list)
44804490
const timelib_tz_lookup_table *table, *entry;
44814491
zval element, *abbr_array_p, abbr_array;
44824492

4493+
ZEND_PARSE_PARAMETERS_NONE();
4494+
44834495
table = timelib_timezone_abbreviations_list();
44844496
array_init(return_value);
44854497
entry = table;
@@ -4940,6 +4952,8 @@ PHP_METHOD(DatePeriod, __wakeup)
49404952
php_period_obj *period_obj;
49414953
HashTable *myht;
49424954

4955+
ZEND_PARSE_PARAMETERS_NONE();
4956+
49434957
period_obj = Z_PHPPERIOD_P(object);
49444958

49454959
myht = Z_OBJPROP_P(object);

ext/dom/node.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1829,6 +1829,10 @@ PHP_METHOD(domnode, getNodePath)
18291829
dom_object *intern;
18301830
char *value;
18311831

1832+
if (zend_parse_parameters_none() == FAILURE) {
1833+
return;
1834+
}
1835+
18321836
DOM_GET_THIS_OBJ(nodep, id, xmlNodePtr, intern);
18331837

18341838
value = (char *) xmlGetNodePath(nodep);

ext/intl/common/common_error.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
*/
2727
PHP_FUNCTION( intl_get_error_code )
2828
{
29+
if (zend_parse_parameters_none() == FAILURE) {
30+
return;
31+
}
32+
2933
RETURN_LONG( intl_error_get_code( NULL ) );
3034
}
3135
/* }}} */
@@ -35,6 +39,10 @@ PHP_FUNCTION( intl_get_error_code )
3539
*/
3640
PHP_FUNCTION( intl_get_error_message )
3741
{
42+
if (zend_parse_parameters_none() == FAILURE) {
43+
return;
44+
}
45+
3846
RETURN_STR(intl_error_get_message( NULL ));
3947
}
4048
/* }}} */

ext/intl/uchar/uchar.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,9 @@ IC_METHOD(getUnicodeVersion) {
559559
UVersionInfo version;
560560
int i;
561561

562+
if (zend_parse_parameters_none() == FAILURE) {
563+
return;
564+
}
562565

563566
u_getUnicodeVersion(version);
564567
array_init(return_value);

ext/mysqli/mysqli_api.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,10 @@ PHP_FUNCTION(mysqli_free_result)
13741374
Get MySQL client info */
13751375
PHP_FUNCTION(mysqli_get_client_info)
13761376
{
1377+
if (zend_parse_parameters_none() == FAILURE) {
1378+
return;
1379+
}
1380+
13771381
const char * info = mysql_get_client_info();
13781382
if (info) {
13791383
RETURN_STRING(info);
@@ -1385,6 +1389,10 @@ PHP_FUNCTION(mysqli_get_client_info)
13851389
Get MySQL client info */
13861390
PHP_FUNCTION(mysqli_get_client_version)
13871391
{
1392+
if (zend_parse_parameters_none() == FAILURE) {
1393+
return;
1394+
}
1395+
13881396
RETURN_LONG((zend_long)mysql_get_client_version());
13891397
}
13901398
/* }}} */
@@ -1485,6 +1493,10 @@ void php_mysqli_init(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_method)
14851493
MYSQLI_RESOURCE *mysqli_resource;
14861494
MY_MYSQL *mysql;
14871495

1496+
if (zend_parse_parameters_none() == FAILURE) {
1497+
return;
1498+
}
1499+
14881500
if (is_method && (Z_MYSQLI_P(getThis()))->ptr) {
14891501
return;
14901502
}
@@ -2619,6 +2631,10 @@ PHP_FUNCTION(mysqli_thread_id)
26192631
Return whether thread safety is given or not */
26202632
PHP_FUNCTION(mysqli_thread_safe)
26212633
{
2634+
if (zend_parse_parameters_none() == FAILURE) {
2635+
return;
2636+
}
2637+
26222638
RETURN_BOOL(mysql_thread_safe());
26232639
}
26242640
/* }}} */

ext/mysqli/mysqli_nonapi.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ PHP_FUNCTION(mysqli_link_construct)
390390
Returns the numerical value of the error message from last connect command */
391391
PHP_FUNCTION(mysqli_connect_errno)
392392
{
393+
if (zend_parse_parameters_none() == FAILURE) {
394+
return;
395+
}
396+
393397
RETURN_LONG(MyG(error_no));
394398
}
395399
/* }}} */
@@ -398,6 +402,10 @@ PHP_FUNCTION(mysqli_connect_errno)
398402
Returns the text of the error message from previous MySQL operation */
399403
PHP_FUNCTION(mysqli_connect_error)
400404
{
405+
if (zend_parse_parameters_none() == FAILURE) {
406+
return;
407+
}
408+
401409
if (MyG(error_msg)) {
402410
RETURN_STRING(MyG(error_msg));
403411
} else {
@@ -1268,10 +1276,10 @@ PHP_FUNCTION(mysqli_release_savepoint)
12681276
Returns information about open and cached links */
12691277
PHP_FUNCTION(mysqli_get_links_stats)
12701278
{
1271-
if (ZEND_NUM_ARGS()) {
1272-
php_error_docref(NULL, E_WARNING, "no parameters expected");
1279+
if (zend_parse_parameters_none() == FAILURE) {
12731280
return;
12741281
}
1282+
12751283
array_init(return_value);
12761284
add_assoc_long_ex(return_value, "total", sizeof("total") - 1, MyG(num_links));
12771285
add_assoc_long_ex(return_value, "active_plinks", sizeof("active_plinks") - 1, MyG(num_active_persistent));

ext/mysqli/tests/mysqli_connect_errno.phpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ require_once('skipifconnectfailure.inc');
1414
$link = NULL;
1515

1616
// too many parameter
17-
if (0 !== ($tmp = @mysqli_connect_errno($link)))
18-
printf("[001] Expecting integer/0, got %s/%s\n", gettype($tmp), $tmp);
17+
try {
18+
mysqli_connect_errno($link);
19+
} catch (ArgumentCountError $exception) {
20+
print($exception->getMessage() . "\n");
21+
}
1922

2023
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
2124
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -36,5 +39,6 @@ require_once('skipifconnectfailure.inc');
3639

3740
print "done!";
3841
?>
39-
--EXPECT--
42+
--EXPECTF--
43+
mysqli_connect_errno() expects exactly 0 parameters, 1 given
4044
done!

ext/mysqli/tests/mysqli_connect_error.phpt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ require_once('skipifconnectfailure.inc');
1414
$link = NULL;
1515

1616
// too many parameter
17-
if (!is_null($tmp = @mysqli_connect_error($link)))
18-
printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
17+
try {
18+
mysqli_connect_error($link);
19+
} catch (ArgumentCountError $exception) {
20+
print($exception->getMessage() . "\n");
21+
}
1922

2023
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
2124
printf("[002] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
@@ -35,5 +38,6 @@ require_once('skipifconnectfailure.inc');
3538

3639
print "done!";
3740
?>
38-
--EXPECT--
41+
--EXPECTF--
42+
mysqli_connect_error() expects exactly 0 parameters, 1 given
3943
done!

ext/mysqli/tests/mysqli_report.phpt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,12 @@ require_once('skipifconnectfailure.inc');
267267
!mysqli_query($link, 'DELETE FROM test WHERE id > 50', MYSQLI_USE_RESULT))
268268
printf("[033] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
269269

270-
$tmp = mysqli_thread_safe($link);
270+
try {
271+
mysqli_thread_safe($link);
272+
} catch (ArgumentCountError $exception) {
273+
print($exception->getMessage() . "\n");
274+
}
275+
271276
$tmp = mysqli_thread_id($link);
272277

273278
mysqli_close($link);
@@ -293,4 +298,5 @@ Warning: mysqli_kill(): processid should have positive value in %s on line %d
293298
Warning: mysqli_stmt_prepare(): (%d/%d): You have an error in your SQL syntax; check the manual that corresponds to your %s server version for the right syntax to use near 'FOO' at line 1 in %s on line %d
294299
[013] Access denied for user '%s'@'%s' (using password: YES)
295300
[016] Access denied for user '%s'@'%s' (using password: YES)
301+
mysqli_thread_safe() expects exactly 0 parameters, 1 given
296302
done!

ext/openssl/openssl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6294,6 +6294,10 @@ PHP_FUNCTION(openssl_get_curve_names)
62946294
size_t i;
62956295
size_t len = EC_get_builtin_curves(NULL, 0);
62966296

6297+
if (zend_parse_parameters_none() == FAILURE) {
6298+
return;
6299+
}
6300+
62976301
curves = emalloc(sizeof(EC_builtin_curve) * len);
62986302
if (!EC_get_builtin_curves(curves, len)) {
62996303
RETURN_FALSE;

ext/pdo/pdo_stmt.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,6 +1627,8 @@ static PHP_METHOD(PDOStatement, rowCount)
16271627
{
16281628
PHP_STMT_GET_OBJ;
16291629

1630+
ZEND_PARSE_PARAMETERS_NONE();
1631+
16301632
RETURN_LONG(stmt->row_count);
16311633
}
16321634
/* }}} */
@@ -2036,6 +2038,8 @@ static PHP_METHOD(PDOStatement, nextRowset)
20362038
{
20372039
PHP_STMT_GET_OBJ;
20382040

2041+
ZEND_PARSE_PARAMETERS_NONE();
2042+
20392043
if (!stmt->methods->next_rowset) {
20402044
pdo_raise_impl_error(stmt->dbh, stmt, "IM001", "driver does not support multiple rowsets");
20412045
RETURN_FALSE;
@@ -2058,6 +2062,8 @@ static PHP_METHOD(PDOStatement, closeCursor)
20582062
{
20592063
PHP_STMT_GET_OBJ;
20602064

2065+
ZEND_PARSE_PARAMETERS_NONE();
2066+
20612067
if (!stmt->methods->cursor_closer) {
20622068
/* emulate it by fetching and discarding rows */
20632069
do {
@@ -2091,6 +2097,8 @@ static PHP_METHOD(PDOStatement, closeCursor)
20912097
A utility for internals hackers to debug parameter internals */
20922098
static PHP_METHOD(PDOStatement, debugDumpParams)
20932099
{
2100+
ZEND_PARSE_PARAMETERS_NONE();
2101+
20942102
php_stream *out = php_stream_open_wrapper("php://output", "w", 0, NULL);
20952103
struct pdo_bound_param_data *param;
20962104
PHP_STMT_GET_OBJ;

ext/pdo_pgsql/pgsql_driver.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,8 @@ static PHP_METHOD(PDO, pgsqlLOBCreate)
920920
pdo_pgsql_db_handle *H;
921921
Oid lfd;
922922

923+
ZEND_PARSE_PARAMETERS_NONE();
924+
923925
dbh = Z_PDO_DBH_P(ZEND_THIS);
924926
PDO_CONSTRUCT_CHECK;
925927
PDO_DBH_CLEAR_ERR();
@@ -1107,6 +1109,8 @@ static PHP_METHOD(PDO, pgsqlGetPid)
11071109
pdo_dbh_t *dbh;
11081110
pdo_pgsql_db_handle *H;
11091111

1112+
ZEND_PARSE_PARAMETERS_NONE();
1113+
11101114
dbh = Z_PDO_DBH_P(ZEND_THIS);
11111115
PDO_CONSTRUCT_CHECK;
11121116

ext/session/session.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2645,6 +2645,8 @@ static PHP_FUNCTION(session_register_shutdown)
26452645
{
26462646
php_shutdown_function_entry shutdown_function_entry;
26472647

2648+
ZEND_PARSE_PARAMETERS_NONE();
2649+
26482650
/* This function is registered itself as a shutdown function by
26492651
* session_set_save_handler($obj). The reason we now register another
26502652
* shutdown function is in case the user registered their own shutdown

0 commit comments

Comments
 (0)