]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
dummynet: Fix socket option length validation for IP_DUMMYNET3
authorMark Johnston <markj@FreeBSD.org>
Mon, 29 Nov 2021 18:50:30 +0000 (13:50 -0500)
committerMark Johnston <markj@FreeBSD.org>
Mon, 6 Dec 2021 14:04:33 +0000 (09:04 -0500)
commitb77d66032f47838c5473d8eee3eea3202a080134
tree27c693de954065a280d27a3f61a4b66d8c8a47c4
parent3f1756dabfe263c279c7dc29c54398d95f8b0988
dummynet: Fix socket option length validation for IP_DUMMYNET3

The socket option handler tries to ensure that the option length is no
larger than some reasonable maximum, and no smaller than sizeof(struct
dn_id).  But the loaded option length is stored in an int, which is
converted to an unsigned integer for the comparison with a size_t, so
negative values are not caught and instead get passed to malloc().

Change the code to use a size_t for the buffer size.

Reviewed by: kp
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 1c732c85911eb9e39071cbdb50dfb1f0d76de40f)
sys/netpfil/ipfw/ip_dn_private.h
sys/netpfil/ipfw/ip_dummynet.c