From 4b3fea3d54f884cc9e72bef630ffa9eb00f84b07 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Tue, 18 Jun 2013 17:50:51 +0200 Subject: [PATCH] kernel-pfroute: Alignment of sockaddrs is not always the same --- src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c index 0dfb2957a..f8eed5775 100644 --- a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c +++ b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c @@ -41,7 +41,13 @@ #endif /** properly align sockaddrs */ +#ifdef __APPLE__ +/* Apple always uses 4 bytes */ #define SA_ALIGN 4 +#else +/* while on other platforms like FreeBSD it depends on the architecture */ +#define SA_ALIGN sizeof(long) +#endif #define SA_LEN(len) ((len) > 0 ? (((len)+SA_ALIGN-1) & ~(SA_ALIGN-1)) : SA_ALIGN) /** delay before firing roam events (ms) */ @@ -349,7 +355,8 @@ METHOD(enumerator_t, rt_enumerate, bool, *addr = this->addr; *xtype = i; this->remaining -= SA_LEN(this->addr->sa_len); - this->addr = (char*)this->addr + SA_LEN(this->addr->sa_len); + this->addr = (struct sockaddr*)((char*)this->addr + + SA_LEN(this->addr->sa_len)); return TRUE; } }