Skip to content

Commit 20d8561

Browse files
authored
fuzzer support for FreeBSD, getting opcache location
Closes phpGH-7926.
1 parent ac1c2dc commit 20d8561

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

sapi/fuzzer/fuzzer-execute-common.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
#include <main/php.h>
1818

19+
#if defined(__FreeBSD__)
20+
# include <sys/sysctl.h>
21+
#endif
22+
1923
#include "fuzzer.h"
2024
#include "fuzzer-sapi.h"
2125
#include "zend_exceptions.h"
@@ -140,7 +144,13 @@ ZEND_ATTRIBUTE_UNUSED char *get_opcache_path(void) {
140144

141145
/* Try relative to binary location. */
142146
char path[MAXPATHLEN];
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) {
151+
#else
143152
if (readlink("/proc/self/exe", path, sizeof(path)) < 0) {
153+
#endif
144154
ZEND_ASSERT(0 && "Failed to get binary path");
145155
return NULL;
146156
}

0 commit comments

Comments
 (0)