Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 843c5f0

Browse files
committed
sapi/fuzzer: Fetch function and call it directly instead of using a zval to hold the name
1 parent 75006cf commit 843c5f0

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

‎sapi/fuzzer/fuzzer-execute-common.h‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,16 @@ ZEND_ATTRIBUTE_UNUSED static void create_file(void) {
127127
ZEND_ATTRIBUTE_UNUSED static void opcache_invalidate(void) {
128128
steps_left = MAX_STEPS;
129129
zend_exception_save();
130-
zval retval, func, args[2];
131-
ZVAL_STRING(&func, "opcache_invalidate");
130+
zval retval, args[2];
131+
zend_function *fn = zend_hash_str_find_ptr(CG(function_table), ZEND_STRL("opcache_invalidate"));
132+
ZEND_ASSERT(fn != NULL);
133+
132134
ZVAL_STRING(&args[0], FILE_NAME);
133135
ZVAL_TRUE(&args[1]);
134-
call_user_function(CG(function_table), NULL, &func, &retval, 2, args);
136+
zend_call_known_function(fn, NULL, NULL, &retval, 2, args, NULL);
135137
ZEND_ASSERT(Z_TYPE(retval) == IS_TRUE);
136138
zval_ptr_dtor(&args[0]);
137139
zval_ptr_dtor(&retval);
138-
zval_ptr_dtor(&func);
139140
zend_exception_restore();
140141
}
141142

‎sapi/fuzzer/fuzzer-sapi.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,11 @@ int fuzzer_do_request_from_buffer(
294294
void fuzzer_call_php_func_zval(const char *func_name, int nargs, zval *args) {
295295
zval retval, func;
296296

297-
ZVAL_STRING(&func, func_name);
297+
zend_function *fn = zend_hash_str_find_ptr(CG(function_table), func_name, strlen(func_name));
298+
ZEND_ASSERT(fn != NULL);
299+
298300
ZVAL_UNDEF(&retval);
299-
call_user_function(CG(function_table), NULL, &func, &retval, nargs, args);
301+
zend_call_known_function(fn, NULL, NULL, &retval, nargs, args, NULL);
300302

301303
// TODO: check result?
302304
/* to ensure retval is not broken */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /