]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
fixup addr6 check.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 15 Oct 2007 14:42:37 +0000 (14:42 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Mon, 15 Oct 2007 14:42:37 +0000 (14:42 +0000)
git-svn-id: file:///svn/unbound/trunk@677 be551aaa-1e26-0410-a405-d3ace91eadb9

doc/Changelog
iterator/iter_utils.c
services/outside_network.c
util/net_help.c
util/net_help.h

index d33539d5f8219daba65aff2fbbe9628584c0c07d..6a2d58c2bb1d61ec11f690d8323fc55987695971 100644 (file)
@@ -4,6 +4,7 @@
        - fixup the fact that the query section was not compressed to,
          the code was there but was called by value instead of by reference.
          And test for the case, uses xxd and nc.
+       - more portable ip6 check for sockaddr types.
 
 8 October 2007: Wouter
        - --disable-rpath option in configure for 64bit systems with
index bfa266ea1d75252bbc8b4e41a7217854b3bc2b50..80ae55d3adc272a85f5b2a34949fae4d998ac5e4 100644 (file)
@@ -136,7 +136,7 @@ iter_filter_unsuitable(struct iter_env* iter_env, struct module_env* env,
        if(donotq_lookup(iter_env->donotq, &a->addr, a->addrlen)) {
                return -1; /* server is on the donotquery list */
        }
-       if(!iter_env->supports_ipv6 && addr_is_ip6(&a->addr)) {
+       if(!iter_env->supports_ipv6 && addr_is_ip6(&a->addr, a->addrlen)) {
                return -1; /* there is no ip6 available */
        }
        /* check lameness - need zone , class info */
index 8e91050952300e691ce6ea7e1b90ea7ce9894f14..986674875bdc30f060a0869ed4311906f9ef13ff 100644 (file)
@@ -124,7 +124,7 @@ outnet_tcp_take_into_use(struct waiting_tcp* w, uint8_t* pkt, size_t pkt_len)
        log_assert(pkt);
        /* open socket */
 #ifdef INET6
-       if(addr_is_ip6(&w->addr))
+       if(addr_is_ip6(&w->addr, w->addrlen))
                s = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP);
        else
 #endif
@@ -643,7 +643,7 @@ select_port(struct outside_network* outnet, struct pending* pend,
 
        log_assert(outnet && pend);
        /* first select ip4 or ip6. */
-       if(addr_is_ip6(&pend->addr))
+       if(addr_is_ip6(&pend->addr, pend->addrlen))
                nummax = (int)outnet->num_udp6;
        else    nummax = (int)outnet->num_udp4;
 
@@ -663,7 +663,7 @@ select_port(struct outside_network* outnet, struct pending* pend,
        if(chosen < 0) chosen = 0;
        if(chosen >= nummax) chosen = nummax-1;
 
-       if(addr_is_ip6(&pend->addr))
+       if(addr_is_ip6(&pend->addr, pend->addrlen))
                pend->c = outnet->udp6_ports[chosen];
        else    pend->c = outnet->udp4_ports[chosen];
        log_assert(pend->c);
index 871199455c71e049192b947ce13586dea38d39ce..bddcf0dbe6c5897c38a77a23f457985bc9a76cd8 100644 (file)
@@ -312,10 +312,10 @@ sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1,
 }
 
 int
-addr_is_ip6(struct sockaddr_storage* addr)
+addr_is_ip6(struct sockaddr_storage* addr, socklen_t len)
 {
-       short family = *(short*)addr;
-       if(family == AF_INET6)
+       if(len == (socklen_t)sizeof(struct sockaddr_in6) &&
+               ((struct sockaddr_in6*)addr)->sin6_family == AF_INET6)
                return 1;
        else    return 0;
 }
index 097e586d15f0f6a200066362207c31267a3da489..83e631e8ed227e659821079f5e77e5f09c09ffa8 100644 (file)
@@ -203,8 +203,9 @@ int sockaddr_cmp(struct sockaddr_storage* addr1, socklen_t len1,
 /**
  * Checkout address family.
  * @param addr: the sockaddr to examine.
+ * @param len: the length of addr.
  * return: true if sockaddr is ip6.
  */
-int addr_is_ip6(struct sockaddr_storage* addr);
+int addr_is_ip6(struct sockaddr_storage* addr, socklen_t len);
 
 #endif /* NET_HELP_H */