From: Tobias Brunner Date: Tue, 18 Jun 2013 15:50:51 +0000 (+0200) Subject: kernel-pfroute: Alignment of sockaddrs is not always the same X-Git-Tag: 5.1.0dr1~80^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b3fea3d54f884cc9e72bef630ffa9eb00f84b07;p=thirdparty%2Fstrongswan.git kernel-pfroute: Alignment of sockaddrs is not always the same --- diff --git a/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c b/src/libhydra/plugins/kernel_pfroute/kernel_pfroute_net.c index 0dfb2957ad..f8eed57750 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; } }