From 46bf534cafc2b6a8fce1dd903cbe7672d3b2d7b0 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Mon, 15 Jan 2018 21:59:20 +0000 Subject: [PATCH] Don't provide a (meaningless) cmsg when proving a notification in a recvmsg() call. MFC after: 1 week --- sys/netinet/sctputil.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/sys/netinet/sctputil.c b/sys/netinet/sctputil.c index 5a004a14962..1ccd886c37c 100644 --- a/sys/netinet/sctputil.c +++ b/sys/netinet/sctputil.c @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include /* for sctp_deliver_data() */ +#include #include #include #include @@ -6094,7 +6094,7 @@ sctp_m_free(struct mbuf *m) return (m_free(m)); } -void +void sctp_m_freem(struct mbuf *mb) { while (mb != NULL) @@ -6164,6 +6164,7 @@ sctp_soreceive(struct socket *so, struct sockaddr *from; struct sctp_extrcvinfo sinfo; int filling_sinfo = 1; + int flags; struct sctp_inpcb *inp; inp = (struct sctp_inpcb *)so->so_pcb; @@ -6191,15 +6192,24 @@ sctp_soreceive(struct socket *so, if (filling_sinfo) { memset(&sinfo, 0, sizeof(struct sctp_extrcvinfo)); } - error = sctp_sorecvmsg(so, uio, mp0, from, fromlen, flagsp, + if (flagsp != NULL) { + flags = *flagsp; + } else { + flags = 0; + } + error = sctp_sorecvmsg(so, uio, mp0, from, fromlen, &flags, (struct sctp_sndrcvinfo *)&sinfo, filling_sinfo); + if (flagsp != NULL) { + *flagsp = flags; + } if (controlp != NULL) { /* copy back the sinfo in a CMSG format */ - if (filling_sinfo) + if (filling_sinfo && ((flags & MSG_NOTIFICATION) == 0)) { *controlp = sctp_build_ctl_nchunk(inp, (struct sctp_sndrcvinfo *)&sinfo); - else + } else { *controlp = NULL; + } } if (psa) { /* copy back the address info */