From f88c9942e1e3d4d463ec71ba5a60d045381bda8f Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 11 Jun 2006 18:53:27 +0000 Subject: [PATCH] Use memcpy() to copy sockaddrs returned by getaddrinfo(). Thanks to Miles Nordin for spotting this. --- THANKS | 1 + src/net_setup.c | 2 +- src/netutl.c | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/THANKS b/THANKS index 21176e2..d469326 100644 --- 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 diff --git a/src/net_setup.c b/src/net_setup.c index b3ce766..d03869e 100644 --- a/src/net_setup.c +++ b/src/net_setup.c @@ -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++; } diff --git a/src/netutl.c b/src/netutl.c index d321fb2..6386e4c 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -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; -- 2.25.1