diff options
Diffstat (limited to 'sbin/isakmpd/util.c')
-rw-r--r-- | sbin/isakmpd/util.c | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/sbin/isakmpd/util.c b/sbin/isakmpd/util.c index 27d1d8491c2..b8465d19bf8 100644 --- a/sbin/isakmpd/util.c +++ b/sbin/isakmpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.22 2001/10/26 12:03:07 ho Exp $ */ +/* $OpenBSD: util.c,v 1.23 2001/10/26 13:29:26 ho Exp $ */ /* $EOM: util.c,v 1.23 2000/11/23 12:22:08 niklas Exp $ */ /* @@ -263,11 +263,11 @@ text2sockaddr (char *address, char *port, struct sockaddr **sa) if (getaddrinfo (address, port, &hints, &ai)) return -1; - *sa = malloc (ai->ai_addr->sa_len); + *sa = malloc (sysdep_sa_len (ai->ai_addr)); if (!sa) return -1; - memcpy (*sa, ai->ai_addr, ai->ai_addr->sa_len); + memcpy (*sa, ai->ai_addr, sysdep_sa_len (ai->ai_addr)); freeaddrinfo (ai); return 0; #else @@ -282,7 +282,9 @@ text2sockaddr (char *address, char *port, struct sockaddr **sa) if (!*sa) return -1; +#ifndef USE_OLD_SOCKADDR (*sa)->sa_len = sz; +#endif (*sa)->sa_family = af; if (inet_pton (af, address, sockaddr_addrdata (*sa)) != 1) { @@ -324,7 +326,7 @@ sockaddr2text (struct sockaddr *sa, char **address, int zflag) int i, j; #ifdef HAVE_GETNAMEINFO - if (getnameinfo (sa, sa->sa_len, buf, sizeof buf, 0, 0, + if (getnameinfo (sa, sysdep_sa_len (sa), buf, sizeof buf, 0, 0, allow_name_lookups ? 0 : NI_NUMERICHOST)) return -1; #else @@ -455,23 +457,13 @@ util_ntoa (char **buf, int af, u_int8_t *addr) struct sockaddr_storage from; struct sockaddr *sfrom = (struct sockaddr *)&from; socklen_t fromlen = sizeof from; - u_int32_t ip4_buf; memset (&from, 0, fromlen); sfrom->sa_family = af; - switch (af) - { - case AF_INET: - sfrom->sa_len = sizeof (struct sockaddr_in); - memcpy (&ip4_buf, addr, sizeof (struct in_addr)); - ((struct sockaddr_in *)sfrom)->sin_addr.s_addr = ip4_buf; - break; - - case AF_INET6: - sfrom->sa_len = sizeof (struct sockaddr_in6); - memcpy (sockaddr_addrdata (sfrom), addr, sizeof (struct in6_addr)); - break; - } +#ifndef USE_OLD_SOCKADDR + sfrom->sa_len = sysdep_sa_len (sfrom); +#endif + memcpy (sockaddr_addrdata (sfrom), addr, sockaddr_addrlen (sfrom)); if (sockaddr2text (sfrom, buf, 0)) { |