Fix detection of the executable directory on NetBSD

This commit is contained in:
Pierre Pronchery 2017-12-13 17:31:55 +01:00
parent 669957afee
commit 80bbafecfc
2 changed files with 6 additions and 1 deletions

View File

@ -82,7 +82,7 @@ void wiegand_add_parity(uint8_t *target, uint8_t *source, uint8_t length);
void xor(unsigned char *dst, unsigned char *src, size_t len);
int32_t le24toh(uint8_t data[3]);
uint32_t le32toh (uint8_t *data);
#endif
void rol(uint8_t *data, const size_t len);
void clean_ascii(unsigned char *buf, size_t len);

View File

@ -559,6 +559,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length)
defined(__FreeBSD_kernel__) || defined(__NetBSD__)
#include <limits.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
@ -576,7 +577,11 @@ int WAI_PREFIX(getExecutablePath)(char* out, int capacity, int* dirname_length)
for (;;)
{
#ifdef KERN_PROC_ARGV
int mib[4] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
#else
int mib[4] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
#endif
size_t size = sizeof(buffer1);
if (sysctl(mib, (u_int)(sizeof(mib) / sizeof(mib[0])), path, &size, NULL, 0) != 0)