php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30783 Apache crash when using ReflectionFunction::getStaticVariables()
Submitted: 2004-11-14 18:26 UTC Modified: 2004-11-14 19:10 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: bekkers at gmail dot com Assigned: helly (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.2 OS: *
Private report: No CVE-ID: None
 [2004-11-14 18:26 UTC] bekkers at gmail dot com
Description:
------------
The problem is that ZEND_METHOD(reflection_function, getStaticVariables) in zend_reflection_api.c does not check wether the function is userdefined or not. Wich apperently makes Apache crash.

I figured the function should look something like this:

/* {{{ proto public array ReflectionFunction::getStaticVariables()
   Returns an associative array containing this function's static variables and their values */
ZEND_METHOD(reflection_function, getStaticVariables)
{
	zval *tmp_copy;
	reflection_object *intern;
	zend_function *fptr;
	
	METHOD_NOTSTATIC_NUMPARAMS(0);
	GET_REFLECTION_OBJECT_PTR(fptr);

	/* Return an empty array in case no static variables exist */
	array_init(return_value);
	if (fptr->type == ZEND_USER_FUNCTION && fptr->op_array.static_variables != NULL) {
		zend_hash_copy(Z_ARRVAL_P(return_value), fptr->op_array.static_variables, (copy_ctor_func_t) zval_add_ref, (void *) &tmp_copy, sizeof(zval *));
	}
}

But I'm not shure and as I haven't (and can't) test it.

Reproduce code:
---------------
<?php
$R = new ReflectionFunction('phpversion');
$R->getStaticVariables();
?>

Expected result:
----------------
The output should be nothing. (Getting the static variables from a C function does not sound logical)

Actual result:
--------------
Apache crashes

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-14 19:10 UTC] helly@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 09:01:30 2024 UTC