Skip to content

Commit bc2d02e

Browse files
authored
Fix fuzzer after opcache became mandatory (#19292)
1 parent c1b129b commit bc2d02e

File tree

3 files changed

+2
-44
lines changed

3 files changed

+2
-44
lines changed

sapi/fuzzer/fuzzer-execute-common.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -139,33 +139,3 @@ ZEND_ATTRIBUTE_UNUSED static void opcache_invalidate(void) {
139139
zval_ptr_dtor(&retval);
140140
zend_exception_restore();
141141
}
142-
143-
ZEND_ATTRIBUTE_UNUSED char *get_opcache_path(void) {
144-
/* Try relative to cwd. */
145-
char *p = realpath("modules/opcache.so", NULL);
146-
if (p) {
147-
return p;
148-
}
149-
150-
/* Try relative to binary location. */
151-
char path[MAXPATHLEN];
152-
#if defined(__FreeBSD__)
153-
size_t pathlen = sizeof(path);
154-
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
155-
if (sysctl(mib, 4, path, &pathlen, NULL, 0) < 0) {
156-
#else
157-
if (readlink("/proc/self/exe", path, sizeof(path)) < 0) {
158-
#endif
159-
ZEND_ASSERT(0 && "Failed to get binary path");
160-
return NULL;
161-
}
162-
163-
/* Get basename. */
164-
char *last_sep = strrchr(path, '/');
165-
if (last_sep) {
166-
*last_sep = '\0';
167-
}
168-
169-
strlcat(path, "/modules/opcache.so", sizeof(path));
170-
return realpath(path, NULL);
171-
}

sapi/fuzzer/fuzzer-function-jit.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,12 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
5050
}
5151

5252
int LLVMFuzzerInitialize(int *argc, char ***argv) {
53-
char *opcache_path = get_opcache_path();
54-
assert(opcache_path && "Failed to determine opcache path");
55-
5653
char ini_buf[512];
5754
snprintf(ini_buf, sizeof(ini_buf),
58-
"zend_extension=%s\n"
5955
"opcache.validate_timestamps=0\n"
6056
"opcache.file_update_protection=0\n"
6157
"opcache.jit_buffer_size=128M\n"
62-
"opcache.protect_memory=1\n",
63-
opcache_path);
64-
free(opcache_path);
58+
"opcache.protect_memory=1\n");
6559

6660
create_file();
6761
fuzzer_init_php_for_execute(ini_buf);

sapi/fuzzer/fuzzer-tracing-jit.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
5454
}
5555

5656
int LLVMFuzzerInitialize(int *argc, char ***argv) {
57-
char *opcache_path = get_opcache_path();
58-
assert(opcache_path && "Failed to determine opcache path");
59-
6057
char ini_buf[512];
6158
snprintf(ini_buf, sizeof(ini_buf),
62-
"zend_extension=%s\n"
6359
"opcache.validate_timestamps=0\n"
6460
"opcache.file_update_protection=0\n"
6561
"opcache.memory_consumption=1024\n"
@@ -71,9 +67,7 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) {
7167
"opcache.jit_max_root_traces=100000\n"
7268
"opcache.jit_max_side_traces=100000\n"
7369
"opcache.jit_max_exit_counters=100000\n"
74-
"opcache.protect_memory=1\n",
75-
opcache_path);
76-
free(opcache_path);
70+
"opcache.protect_memory=1\n");
7771

7872
create_file();
7973
fuzzer_init_php_for_execute(ini_buf);

0 commit comments

Comments
 (0)