diff options
-rw-r--r-- | sys/kern/kern_sysctl.c | 6 | ||||
-rw-r--r-- | sys/netinet/igmp.c | 15 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 16 | ||||
-rw-r--r-- | sys/netinet/ip_icmp.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 15 | ||||
-rw-r--r-- | sys/netinet/ipsec_input.c | 54 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 15 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 15 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 15 | ||||
-rw-r--r-- | sys/netinet6/ip6_divert.c | 16 | ||||
-rw-r--r-- | sys/netinet6/ip6_input.c | 15 | ||||
-rw-r--r-- | sys/netmpls/mpls_raw.c | 9 | ||||
-rw-r--r-- | sys/sys/sysctl.h | 4 |
13 files changed, 82 insertions, 127 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 31705cc6bfa..fae4db42f6e 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.373 2020/06/22 02:45:18 dlg Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.374 2020/08/01 23:41:55 gnezdo Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -917,12 +917,12 @@ sysctl_rdint(void *oldp, size_t *oldlenp, void *newp, int val) * Array of integer values. */ int -sysctl_int_arr(int **valpp, int *name, u_int namelen, void *oldp, +sysctl_int_arr(int **valpp, u_int valplen, int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { if (namelen > 1) return (ENOTDIR); - if (name[0] < 0 || valpp[name[0]] == NULL) + if (name[0] < 0 || name[0] >= valplen || valpp[name[0]] == NULL) return (EOPNOTSUPP); return (sysctl_int(oldp, oldlenp, newp, newlen, valpp[name[0]])); } diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index eeff4d510c7..5ea33fab441 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: igmp.c,v 1.74 2018/10/18 15:46:28 cheloha Exp $ */ +/* $OpenBSD: igmp.c,v 1.75 2020/08/01 23:41:55 gnezdo Exp $ */ /* $NetBSD: igmp.c,v 1.15 1996/02/13 23:41:25 christos Exp $ */ /* @@ -695,14 +695,11 @@ igmp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, return (EPERM); return (igmp_sysctl_igmpstat(oldp, oldlenp, newp)); default: - if (name[0] < IGMPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(igmpctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(igmpctl_vars, nitems(igmpctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index b74c0a2ba4c..76c7ff0768a 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.61 2019/02/04 21:40:52 bluhm Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.62 2020/08/01 23:41:55 gnezdo Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -391,15 +391,11 @@ divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case DIVERTCTL_STATS: return (divert_sysctl_divstat(oldp, oldlenp, newp)); default: - if (name[0] < DIVERTCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(divertctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(divertctl_vars, nitems(divertctl_vars), + name, namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index bfb394bdc82..60f10adc65d 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.181 2018/11/28 08:15:29 claudio Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.182 2020/08/01 23:41:55 gnezdo Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -891,14 +891,10 @@ icmp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, break; default: - if (name[0] < ICMPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(icmpctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - break; - } - error = ENOPROTOOPT; + NET_LOCK(); + error = sysctl_int_arr(icmpctl_vars, nitems(icmpctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); break; } diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index ea27a4d0aaa..1b511d14a4b 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.348 2020/04/12 11:56:52 mpi Exp $ */ +/* $OpenBSD: ip_input.c,v 1.349 2020/08/01 23:41:55 gnezdo Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -1659,14 +1659,11 @@ ip_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (EOPNOTSUPP); #endif default: - if (name[0] < IPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(ipctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (EOPNOTSUPP); + NET_LOCK(); + error = sysctl_int_arr(ipctl_vars, nitems(ipctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet/ipsec_input.c b/sys/netinet/ipsec_input.c index 050dc7b1128..9983322eff6 100644 --- a/sys/netinet/ipsec_input.c +++ b/sys/netinet/ipsec_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipsec_input.c,v 1.171 2020/06/24 22:03:43 cheloha Exp $ */ +/* $OpenBSD: ipsec_input.c,v 1.172 2020/08/01 23:41:55 gnezdo Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -743,14 +743,11 @@ ipsec_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case IPCTL_IPSEC_STATS: return (ipsec_sysctl_ipsecstat(oldp, oldlenp, newp)); default: - if (name[0] < IPSEC_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(ipsecctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (EOPNOTSUPP); + NET_LOCK(); + error = sysctl_int_arr(ipsecctl_vars, nitems(ipsecctl_vars), + name, namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } } @@ -768,14 +765,11 @@ esp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case ESPCTL_STATS: return (esp_sysctl_espstat(oldp, oldlenp, newp)); default: - if (name[0] < ESPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(espctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(espctl_vars, nitems(espctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } } @@ -805,14 +799,11 @@ ah_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case AHCTL_STATS: return ah_sysctl_ahstat(oldp, oldlenp, newp); default: - if (name[0] < AHCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(ahctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(ahctl_vars, nitems(ahctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } } @@ -841,14 +832,11 @@ ipcomp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, case IPCOMPCTL_STATS: return ipcomp_sysctl_ipcompstat(oldp, oldlenp, newp); default: - if (name[0] < IPCOMPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(ipcompctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(ipcompctl_vars, nitems(ipcompctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } } diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 086fd603e19..bf86ceed534 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_usrreq.c,v 1.173 2020/06/18 14:52:51 mpi Exp $ */ +/* $OpenBSD: tcp_usrreq.c,v 1.174 2020/08/01 23:41:55 gnezdo Exp $ */ /* $NetBSD: tcp_usrreq.c,v 1.20 1996/02/13 23:44:16 christos Exp $ */ /* @@ -1115,14 +1115,11 @@ tcp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (error); default: - if (name[0] < TCPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(tcpctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(tcpctl_vars, nitems(tcpctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index d05e1c2ed22..62335421123 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.259 2020/06/21 05:19:27 dlg Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.260 2020/08/01 23:41:56 gnezdo Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -1295,14 +1295,11 @@ udp_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, return (udp_sysctl_udpstat(oldp, oldlenp, newp)); default: - if (name[0] < UDPCTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(udpctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(udpctl_vars, nitems(udpctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 9f609ccff0b..2db284a1bea 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.230 2019/11/29 16:41:01 nayden Exp $ */ +/* $OpenBSD: icmp6.c,v 1.231 2020/08/01 23:41:56 gnezdo Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1908,14 +1908,11 @@ icmp6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, case ICMPV6CTL_STATS: return icmp6_sysctl_icmp6stat(oldp, oldlenp, newp); default: - if (name[0] < ICMPV6CTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(icmpv6ctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return ENOPROTOOPT; + NET_LOCK(); + error = sysctl_int_arr(icmpv6ctl_vars, nitems(icmpv6ctl_vars), + name, namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 352e172b433..d70037e6528 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.60 2019/11/29 16:41:01 nayden Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.61 2020/08/01 23:41:56 gnezdo Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -397,15 +397,11 @@ divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, case DIVERT6CTL_STATS: return (divert6_sysctl_div6stat(oldp, oldlenp, newp)); default: - if (name[0] < DIVERT6CTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(divert6ctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - - return (ENOPROTOOPT); + NET_LOCK(); + error = sysctl_int_arr(divert6ctl_vars, nitems(divert6ctl_vars), + name, namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index e33d0b9c715..64489f53b48 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.226 2020/05/06 07:08:53 mpi Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.227 2020/08/01 23:41:56 gnezdo Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -1438,14 +1438,11 @@ ip6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, case IPV6CTL_SOIIKEY: return (ip6_sysctl_soiikey(oldp, oldlenp, newp, newlen)); default: - if (name[0] < IPV6CTL_MAXID) { - NET_LOCK(); - error = sysctl_int_arr(ipv6ctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); - NET_UNLOCK(); - return (error); - } - return (EOPNOTSUPP); + NET_LOCK(); + error = sysctl_int_arr(ipv6ctl_vars, nitems(ipv6ctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); + NET_UNLOCK(); + return (error); } /* NOTREACHED */ } diff --git a/sys/netmpls/mpls_raw.c b/sys/netmpls/mpls_raw.c index c87158a91cb..dd6c0f62e41 100644 --- a/sys/netmpls/mpls_raw.c +++ b/sys/netmpls/mpls_raw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_raw.c,v 1.16 2019/11/05 08:26:38 claudio Exp $ */ +/* $OpenBSD: mpls_raw.c,v 1.17 2020/08/01 23:41:56 gnezdo Exp $ */ /* * Copyright (C) 1999, 2000 and 2001 AYAME Project, WIDE Project. @@ -57,16 +57,13 @@ int mpls_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen) { - if (name[0] >= MPLSCTL_MAXID) - return (EOPNOTSUPP); - /* Almost all sysctl names at this level are terminal. */ if (namelen != 1) return (ENOTDIR); switch (name[0]) { default: - return sysctl_int_arr(mplsctl_vars, name, namelen, - oldp, oldlenp, newp, newlen); + return sysctl_int_arr(mplsctl_vars, nitems(mplsctl_vars), name, + namelen, oldp, oldlenp, newp, newlen); } } diff --git a/sys/sys/sysctl.h b/sys/sys/sysctl.h index d96c653d6b4..03a32c13e0d 100644 --- a/sys/sys/sysctl.h +++ b/sys/sys/sysctl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sysctl.h,v 1.206 2020/05/10 00:56:06 guenther Exp $ */ +/* $OpenBSD: sysctl.h,v 1.207 2020/08/01 23:41:56 gnezdo Exp $ */ /* $NetBSD: sysctl.h,v 1.16 1996/04/09 20:55:36 cgd Exp $ */ /* @@ -994,7 +994,7 @@ typedef int (sysctlfn)(int *, u_int, void *, size_t *, void *, size_t, struct pr int sysctl_int(void *, size_t *, void *, size_t, int *); int sysctl_int_lower(void *, size_t *, void *, size_t, int *); int sysctl_rdint(void *, size_t *, void *, int); -int sysctl_int_arr(int **, int *, u_int, void *, size_t *, void *, size_t); +int sysctl_int_arr(int **, u_int, int*, u_int, void *, size_t *, void *, size_t); int sysctl_quad(void *, size_t *, void *, size_t, int64_t *); int sysctl_rdquad(void *, size_t *, void *, int64_t); int sysctl_string(void *, size_t *, void *, size_t, char *, size_t); |