diff options
author | gnezdo <gnezdo@cvs.openbsd.org> | 2020-11-04 04:40:14 +0000 |
---|---|---|
committer | gnezdo <gnezdo@cvs.openbsd.org> | 2020-11-04 04:40:14 +0000 |
commit | 99d0a3de7f25f12440abe8e809000bdf2f2ae5d8 (patch) | |
tree | b00b93810aaca977605325f807748d3d2d6c32cd /sys | |
parent | f305268d5ffa07538cb22c90ff8cc94f7d5bd0f7 (diff) |
Use sysctl_int_bounded in bpf_sysctl
Unlike the other cases of sysctl_bounded_arr this one uses a dynamic limit.
OK millert@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/bpf.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 0d900b38e3c..ebb4bc95115 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.192 2020/06/18 23:32:00 dlg Exp $ */ +/* $OpenBSD: bpf.c,v 1.193 2020/11/04 04:40:13 gnezdo Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -1720,32 +1720,16 @@ int bpf_sysctl_locked(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { - int newval; - int error; - switch (name[0]) { case NET_BPF_BUFSIZE: - newval = bpf_bufsize; - error = sysctl_int(oldp, oldlenp, newp, newlen, &newval); - if (error) - return (error); - if (newval < BPF_MINBUFSIZE || newval > bpf_maxbufsize) - return (EINVAL); - bpf_bufsize = newval; - break; + return sysctl_int_bounded(oldp, oldlenp, newp, newlen, + &bpf_bufsize, BPF_MINBUFSIZE, bpf_maxbufsize); case NET_BPF_MAXBUFSIZE: - newval = bpf_maxbufsize; - error = sysctl_int(oldp, oldlenp, newp, newlen, &newval); - if (error) - return (error); - if (newval < BPF_MINBUFSIZE) - return (EINVAL); - bpf_maxbufsize = newval; - break; + return sysctl_int_bounded(oldp, oldlenp, newp, newlen, + &bpf_maxbufsize, BPF_MINBUFSIZE, INT_MAX); default: return (EOPNOTSUPP); } - return (0); } int |