From 60952803044e098682c150b7ed91d4da87f5bb79 Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Fri, 19 Oct 2007 14:36:34 -0500 Subject: Fix a crash in resolve_hosts() caused by an out-of-bounds array reference. (This used to be commit bafcede2c29813f8719fc3b54f94612e72c48043) --- source3/libsmb/namequery.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source3') diff --git a/source3/libsmb/namequery.c b/source3/libsmb/namequery.c index 12e0d01b3b..6585fd751c 100644 --- a/source3/libsmb/namequery.c +++ b/source3/libsmb/namequery.c @@ -1074,7 +1074,6 @@ static NTSTATUS resolve_hosts(const char *name, int name_type, &((struct sockaddr_in *)res->ai_addr)->sin_addr); *return_count += 1; - i++; *return_iplist = SMB_REALLOC_ARRAY(*return_iplist, struct ip_service, @@ -1086,6 +1085,8 @@ static NTSTATUS resolve_hosts(const char *name, int name_type, } (*return_iplist)[i].ip = return_ip; (*return_iplist)[i].port = PORT_NONE; + + i++; } if (ailist) { freeaddrinfo(ailist); -- cgit From 61c4666a897fc85b0eb41e60dcbeb78272bfe5cf Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Fri, 19 Oct 2007 09:06:14 -0500 Subject: Move the test for the AIX specific interface code to the end. This tests goes into an infinite loop on OS X so avoid it. Probably should also be only conditionaly be run on AIX in the first place. (This used to be commit 641d0968da73dca24a3ddaf93451de1200d3c09b) --- source3/configure.in | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 22989dbe53..5d236237a1 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -2962,23 +2962,6 @@ fi ################## # look for a method of finding the list of network interfaces iface=no; -AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ -SAVE_CPPFLAGS="$CPPFLAGS" -CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" -AC_TRY_RUN([ -#define NO_CONFIG_H 1 -#define HAVE_IFACE_AIX 1 -#define AUTOCONF_TEST 1 -#undef _XOPEN_SOURCE_EXTENDED -#include "${srcdir-.}/lib/replace/replace.c" -#include "${srcdir-.}/lib/interfaces.c"], - samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) -CPPFLAGS="$SAVE_CPPFLAGS" -if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then - iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) -fi - -if test $iface = no; then AC_CACHE_CHECK([for iface getifaddrs],samba_cv_HAVE_IFACE_GETIFADDRS,[ SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" @@ -2993,7 +2976,6 @@ CPPFLAGS="$SAVE_CPPFLAGS" if test x"$samba_cv_HAVE_IFACE_GETIFADDRS" = x"yes"; then iface=yes;AC_DEFINE(HAVE_IFACE_GETIFADDRS,1,[Whether iface getifaddrs is available]) fi -fi if test $iface = no; then AC_CACHE_CHECK([for iface ifconf],samba_cv_HAVE_IFACE_IFCONF,[ @@ -3029,6 +3011,24 @@ if test x"$samba_cv_HAVE_IFACE_IFREQ" = x"yes"; then fi fi +if test $iface = no; then +AC_CACHE_CHECK([for iface AIX],samba_cv_HAVE_IFACE_AIX,[ +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS ${SAMBA_CONFIGURE_CPPFLAGS}" +AC_TRY_RUN([ +#define NO_CONFIG_H 1 +#define HAVE_IFACE_AIX 1 +#define AUTOCONF_TEST 1 +#undef _XOPEN_SOURCE_EXTENDED +#include "${srcdir-.}/lib/replace/replace.c" +#include "${srcdir-.}/lib/interfaces.c"], + samba_cv_HAVE_IFACE_AIX=yes,samba_cv_HAVE_IFACE_AIX=no,samba_cv_HAVE_IFACE_AIX=cross)]) +CPPFLAGS="$SAVE_CPPFLAGS" +if test x"$samba_cv_HAVE_IFACE_AIX" = x"yes"; then + iface=yes;AC_DEFINE(HAVE_IFACE_AIX,1,[Whether iface AIX is available]) +fi +fi + dnl test for ipv6 AC_CACHE_CHECK([for ipv6 support],samba_cv_HAVE_IPV6,[ AC_TRY_COMPILE([ -- cgit From 80b7bcb5fbc98964014b5c8082a626aef24c5feb Mon Sep 17 00:00:00 2001 From: "Gerald (Jerry) Carter" Date: Fri, 19 Oct 2007 08:14:12 -0500 Subject: Add test for "struct in6_addr" to the HAVE_IPV6 configure test. Also make use of "if defined(HAVE_IPV6)" rather than testing for AF_INET6 since this is not sufficient on HP-UX 11.11 to ensure a working IPv6 implementation. (This used to be commit 620785df4e57b72471ff0315e22e0d2f28a2b1a5) --- source3/configure.in | 1 + source3/lib/interface.c | 4 ++-- source3/lib/interfaces.c | 4 ++-- source3/lib/util_sock.c | 16 ++++++++-------- source3/smbd/utmp.c | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) (limited to 'source3') diff --git a/source3/configure.in b/source3/configure.in index 5d236237a1..a96e2d91f6 100644 --- a/source3/configure.in +++ b/source3/configure.in @@ -3038,6 +3038,7 @@ AC_TRY_COMPILE([ [ struct sockaddr_storage sa_store; struct addrinfo *ai = NULL; +struct in6_addr in6addr; int s = socket(AF_INET6, SOCK_STREAM, 0); int ret = getaddrinfo(NULL, NULL, NULL, &ai); if (ret != 0) { diff --git a/source3/lib/interface.c b/source3/lib/interface.c index 4892ec1248..0696329fd6 100644 --- a/source3/lib/interface.c +++ b/source3/lib/interface.c @@ -339,7 +339,7 @@ bool make_netmask(struct sockaddr_storage *pss_out, { *pss_out = *pss_in; /* Now apply masklen bits of mask. */ -#if defined(AF_INET6) +#if defined(HAVE_IPV6) if (pss_in->ss_family == AF_INET6) { char *p = (char *)&((struct sockaddr_in6 *)pss_out)->sin6_addr; unsigned int i; @@ -386,7 +386,7 @@ static void make_bcast_or_net(struct sockaddr_storage *pss_out, *pss_out = *pss_in; /* Set all zero netmask bits to 1. */ -#if defined(AF_INET6) +#if defined(HAVE_IPV6) if (pss_in->ss_family == AF_INET6) { p = (char *)&((struct sockaddr_in6 *)pss_out)->sin6_addr; pmask = (char *)&((struct sockaddr_in6 *)nmask)->sin6_addr; diff --git a/source3/lib/interfaces.c b/source3/lib/interfaces.c index 2b93a5ba39..3b15e3e87b 100644 --- a/source3/lib/interfaces.c +++ b/source3/lib/interfaces.c @@ -128,7 +128,7 @@ static int _get_interfaces(struct iface_struct *ifaces, int max_interfaces) continue; } -#ifdef AF_INET6 +#if defined(HAVE_IPV6) if (ifptr->ifa_addr->sa_family == AF_INET6) { copy_size = sizeof(struct sockaddr_in6); } @@ -496,7 +496,7 @@ static int iface_comp(struct iface_struct *i1, struct iface_struct *i2) { int r; -#ifdef AF_INET6 +#if defined(HAVE_IPV6) /* * If we have IPv6 - sort these interfaces lower * than any IPv4 ones. diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c index eb3b35339c..c6b1311cf5 100644 --- a/source3/lib/util_sock.c +++ b/source3/lib/util_sock.c @@ -52,7 +52,7 @@ bool is_ipaddress(const char *str) { int ret = -1; -#if defined(AF_INET6) +#if defined(HAVE_IPV6) struct in6_addr dest6; ret = inet_pton(AF_INET6, str, &dest6); @@ -212,7 +212,7 @@ bool is_loopback_ip_v4(struct in_addr ip) bool is_loopback_addr(const struct sockaddr_storage *pss) { -#if defined(AF_INET6) +#if defined(HAVE_IPV6) if (pss->ss_family == AF_INET) { struct in6_addr *pin6 = &((struct sockaddr_in6 *)pss)->sin6_addr; @@ -243,7 +243,7 @@ bool is_zero_ip_v4(struct in_addr ip) bool is_zero_addr(const struct sockaddr_storage *pss) { -#if defined(AF_INET6) +#if defined(HAVE_IPV6) if (pss->ss_family == AF_INET) { struct in6_addr *pin6 = &((struct sockaddr_in6 *)pss)->sin6_addr; @@ -302,7 +302,7 @@ void in_addr_to_sockaddr_storage(struct sockaddr_storage *ss, sa->sin_addr = ip; } -#ifdef AF_INET6 +#if defined(HAVE_IPV6) /******************************************************************* Convert an IPv6 struct in_addr to a struct sockaddr_storage. ********************************************************************/ @@ -330,7 +330,7 @@ bool same_net(const struct sockaddr_storage *ip1, return false; } -#ifdef AF_INET6 +#if defined(HAVE_IPV6) if (ip1->ss_family == AF_INET6) { struct sockaddr_in6 ip1_6 = *(struct sockaddr_in6 *)ip1; struct sockaddr_in6 ip2_6 = *(struct sockaddr_in6 *)ip2; @@ -370,7 +370,7 @@ bool addr_equal(const struct sockaddr_storage *ip1, return false; } -#ifdef AF_INET6 +#if defined(HAVE_IPV6) if (ip1->ss_family == AF_INET6) { return (memcmp(&((const struct sockaddr_in6 *)ip1)->sin6_addr, &((const struct sockaddr_in6 *)ip2)->sin6_addr, @@ -392,7 +392,7 @@ bool addr_equal(const struct sockaddr_storage *ip1, bool is_address_any(const struct sockaddr_storage *psa) { -#ifdef AF_INET6 +#if defined(HAVE_IPV6) if (psa->ss_family == AF_INET6) { struct sockaddr_in6 *si6 = (struct sockaddr_in6 *)psa; if (memcmp(&in6addr_any, @@ -494,7 +494,7 @@ static int get_socket_port(int fd) return -1; } -#ifdef AF_INET6 +#if defined(HAVE_IPV6) if (sa.ss_family == AF_INET6) { return ntohs(((struct sockaddr_in6 *)&sa)->sin6_port); } diff --git a/source3/smbd/utmp.c b/source3/smbd/utmp.c index e36e2aa042..c2908e33cc 100644 --- a/source3/smbd/utmp.c +++ b/source3/smbd/utmp.c @@ -525,7 +525,7 @@ static bool sys_utmp_fill(struct utmp *u, #if defined(HAVE_UT_UT_HOST) utmp_strcpy(u->ut_host, hostname, sizeof(u->ut_host)); #endif -#if defined(AF_INET6) && defined(HAVE_UT_UT_ADDR_V6) +#if defined(HAVE_IPV6) && defined(HAVE_UT_UT_ADDR_V6) memset(&u->ut_addr_v6, '\0', sizeof(u->ut_addr_v6)); if (ip_addr_str) { struct in6_addr addr; -- cgit