From 70cea01a9ec0be4ef9fd141a16b52e8141a1c94a Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 17 Dec 2007 05:53:37 +0100 Subject: r26487: Cope with systems that don't have struct sockaddr.sa_len. (This used to be commit 56080469ab28ae5a2f456cced34814d9c33480c6) --- source4/lib/replace/getifaddrs.c | 11 +++++++++-- source4/lib/replace/getifaddrs.m4 | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'source4') diff --git a/source4/lib/replace/getifaddrs.c b/source4/lib/replace/getifaddrs.c index e04c023209..b681a8649c 100644 --- a/source4/lib/replace/getifaddrs.c +++ b/source4/lib/replace/getifaddrs.c @@ -53,10 +53,17 @@ void freeifaddrs(struct ifaddrs *ifp) struct sockaddr *sockaddr_dup(struct sockaddr *sa) { - struct sockaddr *ret = calloc(1, sa->sa_len); + struct sockaddr *ret; + socklen_t socklen; +#ifdef HAVE_SOCKADDR_SA_LEN + socklen = sa->sa_len; +#else + socklen = sizeof(struct sockaddr_storage); +#endif + ret = = calloc(1, socklen); if (ret == NULL) return NULL; - memcpy(ret, sa, sa->sa_len); + memcpy(ret, sa, socklen); return ret; } #endif diff --git a/source4/lib/replace/getifaddrs.m4 b/source4/lib/replace/getifaddrs.m4 index 7e6016ed8f..85f08ee6c3 100644 --- a/source4/lib/replace/getifaddrs.m4 +++ b/source4/lib/replace/getifaddrs.m4 @@ -1,5 +1,11 @@ AC_CHECK_HEADERS([ifaddrs.h]) +dnl Used when getifaddrs is not available +AC_CHECK_MEMBERS([struct sockaddr.sa_len], + [AC_DEFINE(HAVE_SOCKADDR_SA_LEN, 1, [Whether struct sockaddr has a sa_len member])], + [], + [#include ]) + dnl test for getifaddrs and freeifaddrs AC_CACHE_CHECK([for getifaddrs and freeifaddrs],samba_cv_HAVE_GETIFADDRS,[ AC_TRY_COMPILE([ -- cgit