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 186f816

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

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include "fuzzer.h"
2424
#include "fuzzer-sapi.h"
2525
#include "zend_exceptions.h"
26+
#include "../../Zend/zend_API.h"
27+
#include "../../Zend/zend_frameless_function.h"
28+
#include "../../Zend/zend_hash.h"
2629

2730
#define FILE_NAME "/tmp/fuzzer.php"
2831
#define MAX_STEPS 1000
@@ -127,15 +130,16 @@ ZEND_ATTRIBUTE_UNUSED static void create_file(void) {
127130
ZEND_ATTRIBUTE_UNUSED static void opcache_invalidate(void) {
128131
steps_left = MAX_STEPS;
129132
zend_exception_save();
130-
zval retval, func, args[2];
131-
ZVAL_STRING(&func, "opcache_invalidate");
133+
zval retval, args[2];
134+
zend_function *fn = zend_hash_str_find_ptr(CG(function_table), ZEND_STRL("opcache_invalidate"));
135+
ZEND_ASSERT(fn != NULL);
136+
132137
ZVAL_STRING(&args[0], FILE_NAME);
133138
ZVAL_TRUE(&args[1]);
134-
call_user_function(CG(function_table), NULL, &func, &retval, 2, args);
139+
zend_call_known_function(fn, NULL, NULL, &retval, 2, args, NULL);
135140
ZEND_ASSERT(Z_TYPE(retval) == IS_TRUE);
136141
zval_ptr_dtor(&args[0]);
137142
zval_ptr_dtor(&retval);
138-
zval_ptr_dtor(&func);
139143
zend_exception_restore();
140144
}
141145

‎sapi/fuzzer/fuzzer-sapi.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@
3030
#include "fuzzer.h"
3131
#include "fuzzer-sapi.h"
3232

33+
#include <string.h>
34+
35+
#include "../../Zend/zend_API.h"
36+
#include "../../Zend/zend_frameless_function.h"
37+
#include "../../Zend/zend_hash.h"
38+
3339
static const char HARDCODED_INI[] =
3440
"html_errors=0\n"
3541
"implicit_flush=1\n"
@@ -294,9 +300,11 @@ int fuzzer_do_request_from_buffer(
294300
void fuzzer_call_php_func_zval(const char *func_name, int nargs, zval *args) {
295301
zval retval, func;
296302

297-
ZVAL_STRING(&func, func_name);
303+
zend_function *fn = zend_hash_str_find_ptr(CG(function_table), func_name, strlen(func_name));
304+
ZEND_ASSERT(fn != NULL);
305+
298306
ZVAL_UNDEF(&retval);
299-
call_user_function(CG(function_table), NULL, &func, &retval, nargs, args);
307+
zend_call_known_function(fn, NULL, NULL, &retval, nargs, args, NULL);
300308

301309
// TODO: check result?
302310
/* to ensure retval is not broken */

0 commit comments

Comments
(0)

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