diff options
| author | 2010-07-20 05:26:06 +0000 | |
|---|---|---|
| committer | 2010-07-20 05:26:06 +0000 | |
| commit | 1c6cf06e2905abe3bb1d5c7942f9138bcc358e6f (patch) | |
| tree | 8b621bea5d2e3c98dd9d7fe434cf1ad716b7e7c4 /usr.sbin/ospf6ctl/parser.c | |
| parent | VGA repost for ATI Radeon X1250IGP (as found on Gateway netbooks and (diff) | |
| download | wireguard-openbsd-1c6cf06e2905abe3bb1d5c7942f9138bcc358e6f.tar.xz wireguard-openbsd-1c6cf06e2905abe3bb1d5c7942f9138bcc358e6f.zip | |
Another hand rolled offsetof(), replace with mask2prefixlen from kroute.c
which was copied from bgpd. Found by deraadt@
Diffstat (limited to 'usr.sbin/ospf6ctl/parser.c')
| -rw-r--r-- | usr.sbin/ospf6ctl/parser.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/ospf6ctl/parser.c b/usr.sbin/ospf6ctl/parser.c index ef1d0e3cc6f..7d076ea7c2e 100644 --- a/usr.sbin/ospf6ctl/parser.c +++ b/usr.sbin/ospf6ctl/parser.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parser.c,v 1.8 2010/01/13 11:33:12 jsg Exp $ */ +/* $OpenBSD: parser.c,v 1.9 2010/07/20 05:26:06 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -343,17 +343,17 @@ parse_prefix(const char *word, struct in6_addr *addr, u_int8_t *prefixlen) u_int8_t mask2prefixlen(struct sockaddr_in6 *sa_in6) { - u_int8_t l = 0, i, len; + u_int8_t l = 0, *ap, *ep; /* * sin6_len is the size of the sockaddr so substract the offset of * the possibly truncated sin6_addr struct. */ - len = sa_in6->sin6_len - - (u_int8_t)(&((struct sockaddr_in6 *)NULL)->sin6_addr); - for (i = 0; i < len; i++) { + ap = (u_int8_t *)&sa_in6->sin6_addr; + ep = (u_int8_t *)sa_in6 + sa_in6->sin6_len; + for (; ap < ep; ap++) { /* this "beauty" is adopted from sbin/route/show.c ... */ - switch (sa_in6->sin6_addr.s6_addr[i]) { + switch (*ap) { case 0xff: l += 8; break; |
