Reorder a calculation in sbreserve so that it does not overflow

with multi-megabyte socket buffer sizes.

PR:		7420
MFC after:	3 weeks
This commit is contained in:
Mike Silbersack 2002-01-06 06:50:54 +00:00
parent e8fbefccdc
commit 5213c50d83
2 changed files with 6 additions and 2 deletions

View File

@ -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)) {

View File

@ -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)) {