Skip to content

Commit 6c630ee

Browse files
committed
Fix #33502: Some nullary functions don't check the number of arguments
We add the missing zend_parse_parameters_none() checks for: * output_reset_rewrite_vars() * func_num_args() * gc_status() * gc_disable() * gc_enable() * gc_enabled() * gc_collect_cycles() * gc_mem_caches() * zend_version()
1 parent 5f5cf8c commit 6c630ee

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ PHP NEWS
33
?? ??? ????, PHP 7.3.0beta1
44

55
- Core:
6+
. Fixed bug #33502 (Some nullary functions don't check the number of
7+
arguments). (cmb)
68
. Fixed bug #76392 (Error relocating sapi/cli/php: unsupported relocation
79
type 37). (Peter Kokot)
810

Zend/zend_builtin_functions.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ int zend_startup_builtin_functions(void) /* {{{ */
338338
Get the version of the Zend Engine */
339339
ZEND_FUNCTION(zend_version)
340340
{
341+
if (zend_parse_parameters_none() == FAILURE) {
342+
return;
343+
}
344+
341345
RETURN_STRINGL(ZEND_VERSION, sizeof(ZEND_VERSION)-1);
342346
}
343347
/* }}} */
@@ -347,6 +351,10 @@ ZEND_FUNCTION(zend_version)
347351
Returns number of freed bytes */
348352
ZEND_FUNCTION(gc_mem_caches)
349353
{
354+
if (zend_parse_parameters_none() == FAILURE) {
355+
return;
356+
}
357+
350358
RETURN_LONG(zend_mm_gc(zend_mm_get_heap()));
351359
}
352360
/* }}} */
@@ -356,6 +364,10 @@ ZEND_FUNCTION(gc_mem_caches)
356364
Returns number of freed zvals */
357365
ZEND_FUNCTION(gc_collect_cycles)
358366
{
367+
if (zend_parse_parameters_none() == FAILURE) {
368+
return;
369+
}
370+
359371
RETURN_LONG(gc_collect_cycles());
360372
}
361373
/* }}} */
@@ -364,6 +376,10 @@ ZEND_FUNCTION(gc_collect_cycles)
364376
Returns status of the circular reference collector */
365377
ZEND_FUNCTION(gc_enabled)
366378
{
379+
if (zend_parse_parameters_none() == FAILURE) {
380+
return;
381+
}
382+
367383
RETURN_BOOL(gc_enabled());
368384
}
369385
/* }}} */
@@ -372,7 +388,13 @@ ZEND_FUNCTION(gc_enabled)
372388
Activates the circular reference collector */
373389
ZEND_FUNCTION(gc_enable)
374390
{
375-
zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
391+
zend_string *key;
392+
393+
if (zend_parse_parameters_none() == FAILURE) {
394+
return;
395+
}
396+
397+
key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
376398
zend_alter_ini_entry_chars(key, "1", sizeof("1")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
377399
zend_string_release_ex(key, 0);
378400
}
@@ -382,7 +404,13 @@ ZEND_FUNCTION(gc_enable)
382404
Deactivates the circular reference collector */
383405
ZEND_FUNCTION(gc_disable)
384406
{
385-
zend_string *key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
407+
zend_string *key;
408+
409+
if (zend_parse_parameters_none() == FAILURE) {
410+
return;
411+
}
412+
413+
key = zend_string_init("zend.enable_gc", sizeof("zend.enable_gc")-1, 0);
386414
zend_alter_ini_entry_chars(key, "0", sizeof("0")-1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME);
387415
zend_string_release_ex(key, 0);
388416
}
@@ -394,6 +422,10 @@ ZEND_FUNCTION(gc_status)
394422
{
395423
zend_gc_status status;
396424

425+
if (zend_parse_parameters_none() == FAILURE) {
426+
return;
427+
}
428+
397429
zend_gc_get_status(&status);
398430

399431
array_init_size(return_value, 3);
@@ -411,6 +443,10 @@ ZEND_FUNCTION(func_num_args)
411443
{
412444
zend_execute_data *ex = EX(prev_execute_data);
413445

446+
if (zend_parse_parameters_none() == FAILURE) {
447+
return;
448+
}
449+
414450
if (ZEND_CALL_INFO(ex) & ZEND_CALL_CODE) {
415451
zend_error(E_WARNING, "func_num_args(): Called from the global scope - no function context");
416452
RETURN_LONG(-1);

main/output.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,10 @@ PHP_FUNCTION(ob_implicit_flush)
15431543
Reset(clear) URL rewriter values */
15441544
PHP_FUNCTION(output_reset_rewrite_vars)
15451545
{
1546+
if (zend_parse_parameters_none() == FAILURE) {
1547+
return;
1548+
}
1549+
15461550
if (php_url_scanner_reset_vars() == SUCCESS) {
15471551
RETURN_TRUE;
15481552
} else {

0 commit comments

Comments
 (0)