From: bluhm Date: Tue, 21 Aug 2018 12:34:11 +0000 (+0000) Subject: If the control message of IP_SENDSRCADDR did not fit into the socket X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=91f7777790c71b6f4a8b0851230592682bec0ef4;p=openbsd 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@ --- 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))) {