summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgnezdo <gnezdo@openbsd.org>2020-08-24 16:00:31 +0000
committergnezdo <gnezdo@openbsd.org>2020-08-24 16:00:31 +0000
commit81f75d37d867fdb5eedf33701b83f94e0a5c5a82 (patch)
treeab31d9288ee3d24601f358befc110c599a9f00c4
parentAdd support for non-localhost fastcgi sockets. (diff)
downloadwireguard-openbsd-81f75d37d867fdb5eedf33701b83f94e0a5c5a82.tar.xz
wireguard-openbsd-81f75d37d867fdb5eedf33701b83f94e0a5c5a82.zip
Convert divert*_sysctl to sysctl_bounded_args
OK sashan
-rw-r--r--sys/netinet/ip_divert.c12
-rw-r--r--sys/netinet/ip_divert.h9
-rw-r--r--sys/netinet6/ip6_divert.c12
-rw-r--r--sys/netinet6/ip6_divert.h9
4 files changed, 18 insertions, 24 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c
index 76c7ff0768a..47716da5887 100644
--- a/sys/netinet/ip_divert.c
+++ b/sys/netinet/ip_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_divert.c,v 1.62 2020/08/01 23:41:55 gnezdo Exp $ */
+/* $OpenBSD: ip_divert.c,v 1.63 2020/08/24 16:00:31 gnezdo Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -57,7 +57,10 @@ u_int divert_recvspace = DIVERT_RECVSPACE;
#define DIVERTHASHSIZE 128
#endif
-int *divertctl_vars[DIVERTCTL_MAXID] = DIVERTCTL_VARS;
+const struct sysctl_bounded_args divertctl_vars[] = {
+ { DIVERTCTL_RECVSPACE, &divert_recvspace, 0, INT_MAX },
+ { DIVERTCTL_SENDSPACE, &divert_sendspace, 0, INT_MAX },
+};
int divbhashsize = DIVERTHASHSIZE;
@@ -392,8 +395,9 @@ divert_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
return (divert_sysctl_divstat(oldp, oldlenp, newp));
default:
NET_LOCK();
- error = sysctl_int_arr(divertctl_vars, nitems(divertctl_vars),
- name, namelen, oldp, oldlenp, newp, newlen);
+ error = sysctl_bounded_arr(divertctl_vars,
+ nitems(divertctl_vars), name, namelen, oldp, oldlenp, newp,
+ newlen);
NET_UNLOCK();
return (error);
}
diff --git a/sys/netinet/ip_divert.h b/sys/netinet/ip_divert.h
index 1b47de3d258..8a6924e7147 100644
--- a/sys/netinet/ip_divert.h
+++ b/sys/netinet/ip_divert.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip_divert.h,v 1.11 2017/11/02 14:01:18 florian Exp $ */
+/* $OpenBSD: ip_divert.h,v 1.12 2020/08/24 16:00:31 gnezdo Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -42,13 +42,6 @@ struct divstat {
{ "stats", CTLTYPE_STRUCT } \
}
-#define DIVERTCTL_VARS { \
- NULL, \
- &divert_recvspace, \
- &divert_sendspace, \
- NULL \
-}
-
#ifdef _KERNEL
#include <sys/percpu.h>
diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c
index d70037e6528..5d071a9a764 100644
--- a/sys/netinet6/ip6_divert.c
+++ b/sys/netinet6/ip6_divert.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.c,v 1.61 2020/08/01 23:41:56 gnezdo Exp $ */
+/* $OpenBSD: ip6_divert.c,v 1.62 2020/08/24 16:00:31 gnezdo Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -58,7 +58,10 @@ u_int divert6_recvspace = DIVERT_RECVSPACE;
#define DIVERTHASHSIZE 128
#endif
-int *divert6ctl_vars[DIVERT6CTL_MAXID] = DIVERT6CTL_VARS;
+const struct sysctl_bounded_args divert6ctl_vars[] = {
+ { DIVERT6CTL_RECVSPACE, &divert6_recvspace, 0, INT_MAX },
+ { DIVERT6CTL_SENDSPACE, &divert6_sendspace, 0, INT_MAX },
+};
int divb6hashsize = DIVERTHASHSIZE;
@@ -398,8 +401,9 @@ divert6_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp,
return (divert6_sysctl_div6stat(oldp, oldlenp, newp));
default:
NET_LOCK();
- error = sysctl_int_arr(divert6ctl_vars, nitems(divert6ctl_vars),
- name, namelen, oldp, oldlenp, newp, newlen);
+ error = sysctl_bounded_arr(divert6ctl_vars,
+ nitems(divert6ctl_vars), name, namelen, oldp, oldlenp,
+ newp, newlen);
NET_UNLOCK();
return (error);
}
diff --git a/sys/netinet6/ip6_divert.h b/sys/netinet6/ip6_divert.h
index c98a5189136..8a463970485 100644
--- a/sys/netinet6/ip6_divert.h
+++ b/sys/netinet6/ip6_divert.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ip6_divert.h,v 1.9 2017/11/02 14:01:18 florian Exp $ */
+/* $OpenBSD: ip6_divert.h,v 1.10 2020/08/24 16:00:31 gnezdo Exp $ */
/*
* Copyright (c) 2009 Michele Marchetto <michele@openbsd.org>
@@ -42,13 +42,6 @@ struct div6stat {
{ "stats", CTLTYPE_STRUCT } \
}
-#define DIVERT6CTL_VARS { \
- NULL, \
- &divert6_recvspace, \
- &divert6_sendspace, \
- NULL \
-}
-
#ifdef _KERNEL
#include <sys/percpu.h>