summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMartijn van Duren <martijn@cvs.openbsd.org>2021-03-23 22:07:37 +0000
committerMartijn van Duren <martijn@cvs.openbsd.org>2021-03-23 22:07:37 +0000
commit9f1cf98b0a85a03fb3c650532a3803e91469d8ad (patch)
treea12a35c1f7e974d1bb5d4760c58521133e822a67 /usr.bin
parent095acdad720307a85f6f32f8066ad71882caca5c (diff)
Fix some ranges and type handling.
OK sthen@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/snmp/snmp.15
-rw-r--r--usr.bin/snmp/snmpc.c22
2 files changed, 18 insertions, 9 deletions
diff --git a/usr.bin/snmp/snmp.1 b/usr.bin/snmp/snmp.1
index 701b8441552..f16dd2fb059 100644
--- a/usr.bin/snmp/snmp.1
+++ b/usr.bin/snmp/snmp.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: snmp.1,v 1.16 2021/03/12 05:18:01 jsg Exp $
+.\" $OpenBSD: snmp.1,v 1.17 2021/03/23 22:07:36 martijn Exp $
.\"
.\" Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org>
.\"
@@ -14,7 +14,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 12 2021 $
+.Dd $Mdocdate: March 23 2021 $
.Dt SNMP 1
.Os
.Sh NAME
@@ -524,7 +524,6 @@ A regular string.
Timeticks in centiseconds.
.It Cm u
Unsigned integer.
-Actually a normal integer for compatibility with netsnmp.
.It Cm x
A hex string.
Similar to a decimal string, but in hexadecimal format.
diff --git a/usr.bin/snmp/snmpc.c b/usr.bin/snmp/snmpc.c
index 854aa4c0df5..e2348c78033 100644
--- a/usr.bin/snmp/snmpc.c
+++ b/usr.bin/snmp/snmpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpc.c,v 1.32 2021/03/03 09:06:20 jsg Exp $ */
+/* $OpenBSD: snmpc.c,v 1.33 2021/03/23 22:07:36 martijn Exp $ */
/*
* Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org>
@@ -799,7 +799,7 @@ snmpc_trap(int argc, char *argv[])
if (clock_gettime(CLOCK_UPTIME, &ts) == -1)
err(1, "clock_gettime");
} else {
- lval = strtonum(argv[1], 0, LLONG_MAX, &errstr);
+ lval = strtonum(argv[1], 0, UINT32_MAX, &errstr);
if (errstr != NULL)
errx(1, "Bad value notation (%s)", argv[1]);
ts.tv_sec = lval / 100;
@@ -1437,7 +1437,7 @@ snmpc_varbindparse(int argc, char *argv[])
*/
goto pastestring;
case 'c':
- lval = strtonum(argv[i + 2], INT32_MIN, INT32_MAX,
+ lval = strtonum(argv[i + 2], 0, UINT32_MAX,
&errstr);
if (errstr != NULL)
errx(1, "%s: Bad value notation (%s)", argv[i],
@@ -1470,9 +1470,8 @@ snmpc_varbindparse(int argc, char *argv[])
tmpstr = endstr + 1;
} while (endstr[0] != '\0');
goto pastestring;
- case 'u':
case 'i':
- lval = strtonum(argv[i + 2], LLONG_MIN, LLONG_MAX,
+ lval = strtonum(argv[i + 2], INT32_MIN, INT32_MAX,
&errstr);
if (errstr != NULL)
errx(1, "%s: Bad value notation (%s)", argv[i],
@@ -1506,7 +1505,7 @@ pastestring:
free(str);
break;
case 't':
- lval = strtonum(argv[i + 2], LLONG_MIN, LLONG_MAX,
+ lval = strtonum(argv[i + 2], 0, UINT32_MAX,
&errstr);
if (errstr != NULL)
errx(1, "%s: Bad value notation (%s)", argv[i],
@@ -1516,6 +1515,17 @@ pastestring:
SNMP_T_TIMETICKS)) == NULL)
err(1, "ober_printf_elements");
break;
+ case 'u':
+ lval = strtonum(argv[i + 2], 0, UINT32_MAX,
+ &errstr);
+ if (errstr != NULL)
+ errx(1, "%s: Bad value notation (%s)", argv[i],
+ argv[i + 2]);
+ if ((varbind = ober_printf_elements(varbind, "{Oit}",
+ &oid, lval, BER_CLASS_APPLICATION,
+ SNMP_T_GAUGE32)) == NULL)
+ err(1, "ober_printf_elements");
+ break;
case 'x':
/* String always shrinks */
if ((str = malloc(strlen(argv[i + 2]))) == NULL)