From 6f4b0fce3a10e5ae65d3dcb2c29cca76741ab818 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Wed, 13 Dec 2017 17:31:55 +0100 Subject: [PATCH] Fix detection of the executable directory on NetBSD --- client/util.c | 2 ++ client/util.h | 2 ++ client/whereami.c | 5 +++++ 3 files changed, 9 insertions(+) diff --git a/client/util.c b/client/util.c index 7e6b407..4a7b2e0 100644 --- a/client/util.c +++ b/client/util.c @@ -704,9 +704,11 @@ void xor(unsigned char *dst, unsigned char *src, size_t len) { int32_t le24toh (uint8_t data[3]) { return (data[2] << 16) | (data[1] << 8) | data[0]; } +#ifndef le32toh uint32_t le32toh (uint8_t *data) { return (uint32_t)( (data[3]<<24) | (data[2]<<16) | (data[1]<<8) | data[0]); } +#endif // RotateLeft - Ultralight, Desfire, works on byte level // 00-01-02 >> 01-02-00 diff --git a/client/util.h b/client/util.h index 8dc56f8..b551449 100644 --- a/client/util.h +++ b/client/util.h @@ -82,7 +82,9 @@ 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]); +#ifndef le32toh 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); diff --git a/client/whereami.c b/client/whereami.c index 6e5e85f..8cc49da 100644 --- a/client/whereami.c +++ b/client/whereami.c @@ -559,6 +559,7 @@ int WAI_PREFIX(getModulePath)(char* out, int capacity, int* dirname_length) defined(__FreeBSD_kernel__) || defined(__NetBSD__) #include +#include #include #include #include @@ -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)