summaryrefslogtreecommitdiff
path: root/sysdep/unix/io.c
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2014-06-26 13:30:27 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2014-06-26 13:30:27 +0200
commit8945f73d946a9323daf8dfc1bf5b3884cf6d7664 (patch)
tree8d1e073804f69d9fe7ca683c4a22dae7bc6be77a /sysdep/unix/io.c
parent9d5960cfa5b4c15ddd48dbab599f864a6aa1e025 (diff)
Ensures that msg_controllen includes last padding.
Although RFC 3542 allows both cases, Theo de Raadt thinks he knows better, and msg_controllen without last padding fails on OpenBSD. Thanks to Job Snijders for the bugreport.
Diffstat (limited to 'sysdep/unix/io.c')
-rw-r--r--sysdep/unix/io.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 5a0c07e5..a5477695 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -705,6 +705,7 @@ sk_prepare_cmsgs6(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
{
struct cmsghdr *cm;
struct in6_pktinfo *pi;
+ int controllen = 0;
msg->msg_control = cbuf;
msg->msg_controllen = cbuflen;
@@ -713,12 +714,13 @@ sk_prepare_cmsgs6(sock *s, struct msghdr *msg, void *cbuf, size_t cbuflen)
cm->cmsg_level = SOL_IPV6;
cm->cmsg_type = IPV6_PKTINFO;
cm->cmsg_len = CMSG_LEN(sizeof(*pi));
+ controllen += CMSG_SPACE(sizeof(*pi));
pi = (struct in6_pktinfo *) CMSG_DATA(cm);
pi->ipi6_ifindex = s->iface ? s->iface->index : 0;
pi->ipi6_addr = ipa_to_in6(s->saddr);
- msg->msg_controllen = cm->cmsg_len;
+ msg->msg_controllen = controllen;
}