1
0
mirror of https://github.com/php/php-src.git synced 2026-03-25 16:52:18 +01:00

fuzzer support for FreeBSD, getting opcache location

Closes GH-7926.
This commit is contained in:
David CARLIER
2022-01-18 14:04:42 +00:00
committed by GitHub
parent ac1c2dcd6a
commit 20d8561ed4

View File

@@ -16,6 +16,10 @@
#include <main/php.h>
#if defined(__FreeBSD__)
# include <sys/sysctl.h>
#endif
#include "fuzzer.h"
#include "fuzzer-sapi.h"
#include "zend_exceptions.h"
@@ -140,7 +144,13 @@ ZEND_ATTRIBUTE_UNUSED char *get_opcache_path(void) {
/* Try relative to binary location. */
char path[MAXPATHLEN];
#if defined(__FreeBSD__)
size_t pathlen = sizeof(path);
int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1};
if (sysctl(mib, 4, path, &pathlen, NULL, 0) < 0) {
#else
if (readlink("/proc/self/exe", path, sizeof(path)) < 0) {
#endif
ZEND_ASSERT(0 && "Failed to get binary path");
return NULL;
}