diff options
| author | itojun <> | 2000-02-29 18:25:52 +0000 |
|---|---|---|
| committer | itojun <> | 2000-02-29 18:25:52 +0000 |
| commit | 9b10897474965bc1e16f684a62cb71941c34c564 (patch) | |
| tree | f61117489164ecba8c5b61d3b3cfaf61fb276e30 /src/lib/libc | |
| parent | 6be216a1a89a8132724fa9e7369d5a2382b63459 (diff) | |
| download | openbsd-9b10897474965bc1e16f684a62cb71941c34c564.tar.gz openbsd-9b10897474965bc1e16f684a62cb71941c34c564.tar.bz2 openbsd-9b10897474965bc1e16f684a62cb71941c34c564.zip | |
fix alignment constraint in IPv6 routing header manipulation (ancillary data).
documented in RFC2292.
from: shin@kame.net
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/net/rthdr.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/lib/libc/net/rthdr.c b/src/lib/libc/net/rthdr.c index 2dff59668e..5cd485889b 100644 --- a/src/lib/libc/net/rthdr.c +++ b/src/lib/libc/net/rthdr.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: rthdr.c,v 1.1 1999/12/11 08:09:11 itojun Exp $ */ | 1 | /* $OpenBSD: rthdr.c,v 1.2 2000/02/29 18:25:52 itojun Exp $ */ |
| 2 | 2 | ||
| 3 | /* | 3 | /* |
| 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. | 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
| @@ -63,7 +63,9 @@ inet6_rthdr_init(bp, type) | |||
| 63 | int type; | 63 | int type; |
| 64 | { | 64 | { |
| 65 | register struct cmsghdr *ch = (struct cmsghdr *)bp; | 65 | register struct cmsghdr *ch = (struct cmsghdr *)bp; |
| 66 | register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(ch + 1); | 66 | register struct ip6_rthdr *rthdr; |
| 67 | |||
| 68 | rthdr = (struct ip6_rthdr *)CMSG_DATA(ch); | ||
| 67 | 69 | ||
| 68 | ch->cmsg_level = IPPROTO_IPV6; | 70 | ch->cmsg_level = IPPROTO_IPV6; |
| 69 | ch->cmsg_type = IPV6_RTHDR; | 71 | ch->cmsg_type = IPV6_RTHDR; |
| @@ -88,7 +90,9 @@ inet6_rthdr_add(cmsg, addr, flags) | |||
| 88 | const struct in6_addr *addr; | 90 | const struct in6_addr *addr; |
| 89 | u_int flags; | 91 | u_int flags; |
| 90 | { | 92 | { |
| 91 | register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1); | 93 | register struct ip6_rthdr *rthdr; |
| 94 | |||
| 95 | rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg); | ||
| 92 | 96 | ||
| 93 | switch(rthdr->ip6r_type) { | 97 | switch(rthdr->ip6r_type) { |
| 94 | case IPV6_RTHDR_TYPE_0: | 98 | case IPV6_RTHDR_TYPE_0: |
| @@ -135,7 +139,9 @@ inet6_rthdr_lasthop(cmsg, flags) | |||
| 135 | struct cmsghdr *cmsg; | 139 | struct cmsghdr *cmsg; |
| 136 | unsigned int flags; | 140 | unsigned int flags; |
| 137 | { | 141 | { |
| 138 | register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1); | 142 | register struct ip6_rthdr *rthdr; |
| 143 | |||
| 144 | rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg); | ||
| 139 | 145 | ||
| 140 | switch(rthdr->ip6r_type) { | 146 | switch(rthdr->ip6r_type) { |
| 141 | case IPV6_RTHDR_TYPE_0: | 147 | case IPV6_RTHDR_TYPE_0: |
| @@ -189,7 +195,9 @@ int | |||
| 189 | inet6_rthdr_segments(cmsg) | 195 | inet6_rthdr_segments(cmsg) |
| 190 | const struct cmsghdr *cmsg; | 196 | const struct cmsghdr *cmsg; |
| 191 | { | 197 | { |
| 192 | register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1); | 198 | register struct ip6_rthdr *rthdr; |
| 199 | |||
| 200 | rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg); | ||
| 193 | 201 | ||
| 194 | switch(rthdr->ip6r_type) { | 202 | switch(rthdr->ip6r_type) { |
| 195 | case IPV6_RTHDR_TYPE_0: | 203 | case IPV6_RTHDR_TYPE_0: |
| @@ -221,7 +229,9 @@ inet6_rthdr_getaddr(cmsg, index) | |||
| 221 | struct cmsghdr *cmsg; | 229 | struct cmsghdr *cmsg; |
| 222 | int index; | 230 | int index; |
| 223 | { | 231 | { |
| 224 | register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1); | 232 | register struct ip6_rthdr *rthdr; |
| 233 | |||
| 234 | rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg); | ||
| 225 | 235 | ||
| 226 | switch(rthdr->ip6r_type) { | 236 | switch(rthdr->ip6r_type) { |
| 227 | case IPV6_RTHDR_TYPE_0: | 237 | case IPV6_RTHDR_TYPE_0: |
| @@ -260,7 +270,9 @@ inet6_rthdr_getflags(cmsg, index) | |||
| 260 | const struct cmsghdr *cmsg; | 270 | const struct cmsghdr *cmsg; |
| 261 | int index; | 271 | int index; |
| 262 | { | 272 | { |
| 263 | register struct ip6_rthdr *rthdr = (struct ip6_rthdr *)(cmsg + 1); | 273 | register struct ip6_rthdr *rthdr; |
| 274 | |||
| 275 | rthdr = (struct ip6_rthdr *)CMSG_DATA(cmsg); | ||
| 264 | 276 | ||
| 265 | switch(rthdr->ip6r_type) { | 277 | switch(rthdr->ip6r_type) { |
| 266 | case IPV6_RTHDR_TYPE_0: | 278 | case IPV6_RTHDR_TYPE_0: |
