Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions sapi/fuzzer/fuzzer-execute-common.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,16 @@ ZEND_ATTRIBUTE_UNUSED static void create_file(void) {
ZEND_ATTRIBUTE_UNUSED static void opcache_invalidate(void) {
steps_left = MAX_STEPS;
zend_exception_save();
zval retval, func, args[2];
ZVAL_STRING(&func, "opcache_invalidate");
zval retval, args[2];
zend_function *fn = zend_hash_str_find_ptr(CG(function_table), ZEND_STRL("opcache_invalidate"));
ZEND_ASSERT(fn != NULL);

ZVAL_STRING(&args[0], FILE_NAME);
ZVAL_TRUE(&args[1]);
call_user_function(CG(function_table), NULL, &func, &retval, 2, args);
zend_call_known_function(fn, NULL, NULL, &retval, 2, args, NULL);
ZEND_ASSERT(Z_TYPE(retval) == IS_TRUE);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&retval);
zval_ptr_dtor(&func);
zend_exception_restore();
}

Expand Down
6 changes: 4 additions & 2 deletions sapi/fuzzer/fuzzer-sapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,11 @@ int fuzzer_do_request_from_buffer(
void fuzzer_call_php_func_zval(const char *func_name, int nargs, zval *args) {
zval retval, func;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You still have the func variable, which is still zval_ptr_dtor'ed at the end. That will now operate on uninitialized memory because it's never filled in / used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch


ZVAL_STRING(&func, func_name);
zend_function *fn = zend_hash_str_find_ptr(CG(function_table), func_name, strlen(func_name));
ZEND_ASSERT(fn != NULL);

ZVAL_UNDEF(&retval);
call_user_function(CG(function_table), NULL, &func, &retval, nargs, args);
zend_call_known_function(fn, NULL, NULL, &retval, nargs, args, NULL);

// TODO: check result?
/* to ensure retval is not broken */
Expand Down