diff options
author | silby <silby@FreeBSD.org> | 2002-01-06 06:50:54 +0000 |
---|---|---|
committer | silby <silby@FreeBSD.org> | 2002-01-06 06:50:54 +0000 |
commit | 719af3e61a9a9dd18c1117e10400b8bc7591f222 (patch) | |
tree | 184bfcbf0b6ce0f5b8a41fa08b58eab1e38c8c0b /sys/kern/uipc_sockbuf.c | |
parent | 978f7cc92e20c31178dda0730102e3b8206b252f (diff) | |
download | FreeBSD-src-719af3e61a9a9dd18c1117e10400b8bc7591f222.zip FreeBSD-src-719af3e61a9a9dd18c1117e10400b8bc7591f222.tar.gz |
Reorder a calculation in sbreserve so that it does not overflow
with multi-megabyte socket buffer sizes.
PR: 7420
MFC after: 3 weeks
Diffstat (limited to 'sys/kern/uipc_sockbuf.c')
-rw-r--r-- | sys/kern/uipc_sockbuf.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sys/kern/uipc_sockbuf.c b/sys/kern/uipc_sockbuf.c index dc1f4cb..305aaad 100644 --- a/sys/kern/uipc_sockbuf.c +++ b/sys/kern/uipc_sockbuf.c @@ -422,7 +422,9 @@ sbreserve(sb, cc, so, td) * td will only be NULL when we're in an interrupt * (e.g. in tcp_input()) */ - if ((u_quad_t)cc > (u_quad_t)sb_max * MCLBYTES / (MSIZE + MCLBYTES)) + if (sb_max < MSIZE + MCLBYTES) + sb_max = MSIZE + MCLBYTES; + if ((u_quad_t)cc > (u_quad_t)(MCLBYTES * (sb_max / (MSIZE + MCLBYTES)))) return (0); if (!chgsbsize(so->so_cred->cr_uidinfo, &sb->sb_hiwat, cc, td ? td->td_proc->p_rlimit[RLIMIT_SBSIZE].rlim_cur : RLIM_INFINITY)) { |