summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-29 19:16:47 +0000
committerJun-ichiro itojun Hagino <itojun@cvs.openbsd.org>2000-02-29 19:16:47 +0000
commit6cda7c6496d84b2bd19ee3c2c99e825dc3188a58 (patch)
treef09edea2e934722c3f8d6611240fa77dfa3d039c /sys
parent667eae3f1cdc990874646783e3d8028d52b1bbcc (diff)
more fix to ancillary data alignment. we need padding after
last cmsg_data item (see the figure on RFC2292 page 18).
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_socket2.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/kern/uipc_socket2.c b/sys/kern/uipc_socket2.c
index e7f6587a859..4dd7419a52a 100644
--- a/sys/kern/uipc_socket2.c
+++ b/sys/kern/uipc_socket2.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_socket2.c,v 1.13 2000/02/18 05:21:01 itojun Exp $ */
+/* $OpenBSD: uipc_socket2.c,v 1.14 2000/02/29 19:16:46 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 (CMSG_LEN(size) > MCLBYTES) {
+ if (CMSG_SPACE(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 (CMSG_LEN(size) > MLEN) {
+ if (CMSG_SPACE(size) > MLEN) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_free(m);
@@ -808,9 +808,8 @@ sbcreatecontrol(p, size, type, level)
}
cp = mtod(m, struct cmsghdr *);
bcopy(p, CMSG_DATA(cp), size);
- size = CMSG_LEN(size);
- m->m_len = size;
- cp->cmsg_len = size;
+ m->m_len = CMSG_SPACE(size);
+ cp->cmsg_len = CMSG_LEN(size);
cp->cmsg_level = level;
cp->cmsg_type = type;
return (m);