summaryrefslogtreecommitdiff
path: root/sbin/ipsecctl/ike.c
diff options
context:
space:
mode:
authorTodd T. Fries <todd@cvs.openbsd.org>2006-06-08 20:52:44 +0000
committerTodd T. Fries <todd@cvs.openbsd.org>2006-06-08 20:52:44 +0000
commit43fb126db761ce97537742dcf7bc1f01ccb6e78b (patch)
treed0e38791bb9e774e7215164f3140344b38bb75e4 /sbin/ipsecctl/ike.c
parent6b7c1cf0ef8e73d0349042649c5faa460aac5c5b (diff)
allocate enough storage via sockaddr_storage for sockaddr_in6,
fixes ike29.in in regress looks right hshoexer@, ok naddy@
Diffstat (limited to 'sbin/ipsecctl/ike.c')
-rw-r--r--sbin/ipsecctl/ike.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/sbin/ipsecctl/ike.c b/sbin/ipsecctl/ike.c
index 2553102ee3f..fda820ebc00 100644
--- a/sbin/ipsecctl/ike.c
+++ b/sbin/ipsecctl/ike.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ike.c,v 1.37 2006/06/08 18:25:50 hshoexer Exp $ */
+/* $OpenBSD: ike.c,v 1.38 2006/06/08 20:52:43 todd Exp $ */
/*
* Copyright (c) 2005 Hans-Joerg Hoexer <hshoexer@openbsd.org>
*
@@ -379,27 +379,28 @@ ike_section_qmids(u_int8_t proto, struct ipsec_addr_wrap *src,
u_int16_t sport, struct ipsec_addr_wrap *dst, u_int16_t dport, FILE *fd)
{
char mask[NI_MAXHOST], *network, *p;
- struct sockaddr sa;
+ struct sockaddr_storage sas;
+ struct sockaddr *sa = (struct sockaddr *)&sas;
if (src->netaddress) {
- bzero(&sa, sizeof(struct sockaddr));
+ bzero(&sas, sizeof(struct sockaddr_storage));
bzero(mask, sizeof(mask));
- sa.sa_family = src->af;
+ sa->sa_family = src->af;
switch (src->af) {
case AF_INET:
- sa.sa_len = sizeof(struct sockaddr_in);
+ sa->sa_len = sizeof(struct sockaddr_in);
bcopy(&src->mask.ipa,
- &((struct sockaddr_in *)(&sa))->sin_addr,
+ &((struct sockaddr_in *)(sa))->sin_addr,
sizeof(struct in6_addr));
break;
case AF_INET6:
- sa.sa_len = sizeof(struct sockaddr_in6);
+ sa->sa_len = sizeof(struct sockaddr_in6);
bcopy(&src->mask.ipa,
- &((struct sockaddr_in6 *)(&sa))->sin6_addr,
+ &((struct sockaddr_in6 *)sa)->sin6_addr,
sizeof(struct in6_addr));
break;
}
- if (getnameinfo(&sa, sa.sa_len, mask, sizeof(mask), NULL, 0,
+ if (getnameinfo(sa, sa->sa_len, mask, sizeof(mask), NULL, 0,
NI_NUMERICHOST))
errx(1, "could not get a numeric mask");
@@ -422,24 +423,24 @@ ike_section_qmids(u_int8_t proto, struct ipsec_addr_wrap *src,
src->name);
}
if (dst->netaddress) {
- bzero(&sa, sizeof(struct sockaddr));
+ bzero(&sas, sizeof(struct sockaddr_storage));
bzero(mask, sizeof(mask));
- sa.sa_family = dst->af;
+ sa->sa_family = dst->af;
switch (dst->af) {
case AF_INET:
- sa.sa_len = sizeof(struct sockaddr_in);
+ sa->sa_len = sizeof(struct sockaddr_in);
bcopy(&dst->mask.ipa,
- &((struct sockaddr_in *)(&sa))->sin_addr,
+ &((struct sockaddr_in *)(sa))->sin_addr,
sizeof(struct in6_addr));
break;
case AF_INET6:
- sa.sa_len = sizeof(struct sockaddr_in6);
+ sa->sa_len = sizeof(struct sockaddr_in6);
bcopy(&dst->mask.ipa,
- &((struct sockaddr_in6 *)(&sa))->sin6_addr,
+ &((struct sockaddr_in6 *)(sa))->sin6_addr,
sizeof(struct in6_addr));
break;
}
- if (getnameinfo(&sa, sa.sa_len, mask, sizeof(mask), NULL, 0,
+ if (getnameinfo(sa, sa->sa_len, mask, sizeof(mask), NULL, 0,
NI_NUMERICHOST))
errx(1, "could not get a numeric mask");