Skip to content

Commit b732b6d

Browse files
committed
Try to fetch opcache.so path relative to binary
While the cwd-relative lookup worked for the oss-fuzz docker images, it doesn't seem to work on the cluster infrastructure. Try finding opcache.so relative to the binary instead.
1 parent ac34648 commit b732b6d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

sapi/fuzzer/fuzzer-execute-common.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,18 @@ ZEND_ATTRIBUTE_UNUSED static void opcache_invalidate(void) {
126126
}
127127

128128
ZEND_ATTRIBUTE_UNUSED char *get_opcache_path(void) {
129-
// TODO: Make this more general.
130-
char *opcache_path = "modules/opcache.so";
131-
return realpath(opcache_path, NULL);
129+
/* Try relative to cwd. */
130+
char *p = realpath("modules/opcache.so", NULL);
131+
if (p) {
132+
return p;
133+
}
134+
135+
/* Try relative to binary location. */
136+
char path[MAXPATHLEN];
137+
if (readlink("/proc/self/exe", path, sizeof(path)) < 0) {
138+
ZEND_ASSERT(0 && "Failed to get binary path");
139+
return NULL;
140+
}
141+
strlcat(path, "/modules/opcache.so", sizeof(path));
142+
return realpath(path, NULL);
132143
}

0 commit comments

Comments
 (0)