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:
parent
e8fbefccdc
commit
5213c50d83
@ -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)) {
|
||||
|
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user