diff options
author | 2000-02-18 05:21:01 +0000 | |
---|---|---|
committer | 2000-02-18 05:21:01 +0000 | |
commit | d51f4bfb0bf1f6da4e951e46dd8077ab882160a9 (patch) | |
tree | 9d03c7b2685ef8bcfb00716595eff4080c84d2fa | |
parent | do not perform sleep() every time we get ECONNREFUSED. (diff) | |
download | wireguard-openbsd-d51f4bfb0bf1f6da4e951e46dd8077ab882160a9.tar.xz wireguard-openbsd-d51f4bfb0bf1f6da4e951e46dd8077ab882160a9.zip |
fix alignment problem in ancillary data (alpha).
only ipv6 tools (which touches ancillary data) are affected.
From: =?iso-8859-1?Q?G=F6ran_Bengtson?= <goeran@cdg.chalmers.se>
-rw-r--r-- | sys/kern/uipc_socket2.c | 8 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 4 | ||||
-rw-r--r-- | sys/sys/socket.h | 8 |
3 files changed, 11 insertions, 9 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c index 32fb9072e47..e7f6587a859 100644 --- a/sys/kern/uipc_socket2.c +++ b/sys/kern/uipc_socket2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket2.c,v 1.12 2000/02/04 20:32:04 angelos Exp $ */ +/* $OpenBSD: uipc_socket2.c,v 1.13 2000/02/18 05:21:01 itojun Exp $ */ /* $NetBSD: uipc_socket2.c,v 1.11 1996/02/04 02:17:55 christos Exp $ */ /* @@ -792,14 +792,14 @@ sbcreatecontrol(p, size, type, level) register struct cmsghdr *cp; struct mbuf *m; - if (size + sizeof(*cp) > MCLBYTES) { + if (CMSG_LEN(size) > MCLBYTES) { printf("sbcreatecontrol: message too large %d\n", size); return NULL; } if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL) return ((struct mbuf *) NULL); - if (size + sizeof(*cp) > MLEN) { + if (CMSG_LEN(size) > MLEN) { MCLGET(m, M_DONTWAIT); if ((m->m_flags & M_EXT) == 0) { m_free(m); @@ -808,7 +808,7 @@ sbcreatecontrol(p, size, type, level) } cp = mtod(m, struct cmsghdr *); bcopy(p, CMSG_DATA(cp), size); - size += sizeof(*cp); + size = CMSG_LEN(size); m->m_len = size; cp->cmsg_len = size; cp->cmsg_level = level; diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index aa082a2499b..5114a17bb3a 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.38 2000/02/07 06:09:09 itojun Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.39 2000/02/18 05:21:01 itojun Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -618,7 +618,7 @@ udp_saveopt(p, size, type) return ((struct mbuf *) NULL); cp = (struct cmsghdr *) mtod(m, struct cmsghdr *); bcopy(p, CMSG_DATA(cp), size); - size += sizeof(*cp); + size = CMSG_LEN(size); m->m_len = size; cp->cmsg_len = size; cp->cmsg_level = IPPROTO_IP; diff --git a/sys/sys/socket.h b/sys/sys/socket.h index eb1e34226b6..680042fa223 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.30 1999/12/08 06:50:24 itojun Exp $ */ +/* $OpenBSD: socket.h,v 1.31 2000/02/18 05:21:01 itojun Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -342,11 +342,13 @@ struct cmsghdr { }; /* given pointer to struct cmsghdr, return pointer to data */ -#define CMSG_DATA(cmsg) ((u_char *)((cmsg) + 1)) +#define CMSG_DATA(cmsg) \ + ((u_char *)(cmsg) + CMSG_ALIGN(sizeof(struct cmsghdr))) /* given pointer to struct cmsghdr, return pointer to next cmsghdr */ #define CMSG_NXTHDR(mhdr, cmsg) \ - (((caddr_t)(cmsg) + (cmsg)->cmsg_len + sizeof(struct cmsghdr) > \ + (((caddr_t)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len) + \ + CMSG_ALIGN(sizeof(struct cmsghdr)) > \ (mhdr)->msg_control + (mhdr)->msg_controllen) ? \ (struct cmsghdr *)NULL : \ (struct cmsghdr *)((caddr_t)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len))) |