diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-08-21 12:34:12 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2018-08-21 12:34:12 +0000 |
commit | e93f83f18dd459650ddbf98aa2dbd005d663f074 (patch) | |
tree | 8ee391d2a7498408826c44558a225d5e61c58f55 /sys | |
parent | e632c8506e1eb67e431c25dece7d0e771ff8c69f (diff) |
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@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/uipc_socket.c | 14 |
1 files changed, 9 insertions, 5 deletions
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))) { |