Use memcpy() to copy sockaddrs returned by getaddrinfo().
authorGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 Jun 2006 18:53:27 +0000 (18:53 +0000)
committerGuus Sliepen <guus@tinc-vpn.org>
Sun, 11 Jun 2006 18:53:27 +0000 (18:53 +0000)
Thanks to Miles Nordin for spotting this.

THANKS
src/net_setup.c
src/netutl.c

diff --git a/THANKS b/THANKS
index 21176e2..d469326 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -20,6 +20,7 @@ We would like to thank the following people for their contributions to tinc:
 * Mark Glines
 * Martin Kihlgren
 * Matias Carrasco
+* Miles Nordin
 * Nick Patavalis
 * Paul Littlefield
 * Robert van der Meulen
index b3ce766..d03869e 100644 (file)
@@ -502,7 +502,7 @@ bool setup_myself(void)
                        free(hostname);
                }
 
-               listen_socket[listen_sockets].sa.sa = *aip->ai_addr;
+               memcpy(&listen_socket[listen_sockets].sa, aip->ai_addr, aip->ai_addrlen);
                listen_sockets++;
        }
 
index d321fb2..6386e4c 100644 (file)
@@ -78,7 +78,7 @@ sockaddr_t str2sockaddr(const char *address, const char *port)
                return result;
        }
 
-       result = *(sockaddr_t *) ai->ai_addr;
+       memcpy(&result, ai->ai_addr, ai->ai_addrlen);
        freeaddrinfo(ai);
 
        return result;