From e93f83f18dd459650ddbf98aa2dbd005d663f074 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Tue, 21 Aug 2018 12:34:12 +0000 Subject: If the control message of IP_SENDSRCADDR did not fit into the socket buffer together with an UDP packet, sosend(9) returned EWOULDBLOCK. As it is an persistent problem, EMSGSIZE is the correct error code. Split the AF_UNIX case into a separate condition and do not change its logic. For atomic protocols, check that both data and control message length fit into the socket buffer. original bug report from Alexander Markert discussed with jca@; OK vgross@ --- sys/kern/uipc_socket.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'sys') diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index f3806dce272..d50b6dd1914 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.226 2018/07/30 12:22:14 mpi Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.227 2018/08/21 12:34:11 bluhm Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -462,10 +462,14 @@ restart: space = sbspace(so, &so->so_snd); if (flags & MSG_OOB) space += 1024; - if ((atomic && resid > so->so_snd.sb_hiwat) || - (so->so_proto->pr_domain->dom_family != AF_UNIX && - clen > so->so_snd.sb_hiwat)) - snderr(EMSGSIZE); + if (so->so_proto->pr_domain->dom_family == AF_UNIX) { + if (atomic && resid > so->so_snd.sb_hiwat) + snderr(EMSGSIZE); + } else { + if (clen > so->so_snd.sb_hiwat || + (atomic && resid > so->so_snd.sb_hiwat - clen)) + snderr(EMSGSIZE); + } if (space < clen || (space - clen < resid && (atomic || space < so->so_snd.sb_lowat))) { -- cgit v1.2.3