diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-06-23 00:22:04 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-06-23 00:22:04 +0000 |
commit | 86e72bb566b1979b369f8a91b70a91b54e75a9b5 (patch) | |
tree | 4b370859c1f317c7190416443bdc0632adfa9011 /sys/kern | |
parent | f59b2daf2885b6bba8bbd41dd0cde389f07f1a96 (diff) |
for SO_SND*/SO_RCV*, clip low-end of parameter to 1
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/uipc_socket.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 28865a47cea..1503e24315c 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.12 1997/06/06 11:12:13 deraadt Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.13 1997/06/23 00:22:03 deraadt Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -890,30 +890,37 @@ sosetopt(so, level, optname, m0) case SO_RCVBUF: case SO_SNDLOWAT: case SO_RCVLOWAT: + { + u_long cnt; + if (m == NULL || m->m_len < sizeof (int)) { error = EINVAL; goto bad; } + bufsize = *mtod(m, int *); + if ((long)cnt <= 0) + cnt = 1; switch (optname) { case SO_SNDBUF: case SO_RCVBUF: if (sbreserve(optname == SO_SNDBUF ? &so->so_snd : &so->so_rcv, - (u_long) *mtod(m, int *)) == 0) { + cnt) == 0) { error = ENOBUFS; goto bad; } break; case SO_SNDLOWAT: - so->so_snd.sb_lowat = *mtod(m, int *); + so->so_snd.sb_lowat = (long)cnt; break; case SO_RCVLOWAT: - so->so_rcv.sb_lowat = *mtod(m, int *); + so->so_rcv.sb_lowat = (long)cnt; break; } break; + } case SO_SNDTIMEO: case SO_RCVTIMEO: |