19#if defined(__FreeBSD__)
20# include <sys/sysctl.h>
27#define FILE_NAME "/tmp/fuzzer.php"
29#define MAX_SIZE (8 * 1024)
30static uint32_t steps_left;
31static bool bailed_out =
false;
43 if (--steps_left == 0) {
77 return orig_compile_string(str, filename, position);
86 for (uint32_t i = 0; i <
num_args; i++) {
98static void fuzzer_init_php_for_execute(
const char *extra_ini) {
101 putenv(
"USE_TRACKED_ALLOC=1");
147#if defined(__FreeBSD__)
148 size_t pathlen =
sizeof(path);
149 int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
150 if (sysctl(mib, 4, path, &pathlen,
NULL, 0) < 0) {
152 if (
readlink(
"/proc/self/exe", path,
sizeof(path)) < 0) {
159 char *last_sep =
strrchr(path,
'/');
164 strlcat(path,
"/modules/opcache.so",
sizeof(path));
putenv(string $assignment)
strrchr(string $haystack, string $needle, bool $before_needle=false)
fopen(string $filename, string $mode, bool $use_include_path=false, $context=null)
ZEND_ATTRIBUTE_UNUSED char * get_opcache_path(void)
int fuzzer_init_php(const char *extra_ini)
opcache_invalidate(string $filename, bool $force=false)
#define ZVAL_STRING(z, s)
#define call_user_function(function_table, object, function_name, retval_ptr, param_count, params)
ZEND_API zend_op_array *(* zend_compile_string)(zend_string *source_string, const char *filename, zend_compile_position position)
enum _zend_compile_position zend_compile_position
struct _zend_op_array zend_op_array
#define ZEND_CALL_NUM_ARGS(call)
#define ZEND_CALL_VAR_NUM(call, n)
void zend_exception_restore(void)
void zend_exception_save(void)
ZEND_API void execute_internal(zend_execute_data *execute_data, zval *return_value)
ZEND_API void(ZEND_FASTCALL *zend_touch_vm_stack_data)(void *vm_stack_data)
ZEND_API void(* zend_execute_ex)(zend_execute_data *execute_data)
ZEND_API void(* zend_execute_internal)(zend_execute_data *execute_data, zval *return_value)
struct _zend_string zend_string
#define ZEND_ATTRIBUTE_UNUSED
#define zend_always_inline
#define Z_STRLEN_P(zval_p)
struct _zend_execute_data zend_execute_data
ZEND_API void zval_ptr_dtor(zval *zval_ptr)
fbc internal_function handler(call, ret)
ZEND_OPCODE_HANDLER_RET(ZEND_FASTCALL * opcode_handler_t)(ZEND_OPCODE_HANDLER_ARGS)