summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlum <lum@openbsd.org>2021-03-23 15:22:25 +0000
committerlum <lum@openbsd.org>2021-03-23 15:22:25 +0000
commit8fa758803dc2a7f8cb36e7f080e06be50718aea2 (patch)
tree8cd729d0c7ff6602f06ed8a2f74332e69479a269
parentDocument the @version suffix that can be added when running 'portgen go' (diff)
downloadwireguard-openbsd-8fa758803dc2a7f8cb36e7f080e06be50718aea2.tar.xz
wireguard-openbsd-8fa758803dc2a7f8cb36e7f080e06be50718aea2.zip
Make a parameter to an mg function not throw an error just
because it is numerical.
-rw-r--r--usr.bin/mg/interpreter.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/mg/interpreter.c b/usr.bin/mg/interpreter.c
index c47616ae893..d71ce4159f3 100644
--- a/usr.bin/mg/interpreter.c
+++ b/usr.bin/mg/interpreter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interpreter.c,v 1.12 2021/03/22 09:26:23 lum Exp $ */
+/* $OpenBSD: interpreter.c,v 1.13 2021/03/23 15:22:25 lum Exp $ */
/*
* This file is in the public domain.
*
@@ -43,6 +43,8 @@
*
*/
#include <sys/queue.h>
+
+#include <limits.h>
#include <regex.h>
#include <signal.h>
#include <stdio.h>
@@ -384,8 +386,15 @@ multiarg(char *funstr)
spc = 1;
fin = 0;
continue;
- } else
- return (dobeep_msgs("Var not found:", argp));
+ } else {
+ const char *errstr;
+ int iters;
+
+ iters = strtonum(argp, 0, INT_MAX, &errstr);
+ if (errstr != NULL)
+ return (dobeep_msgs("Var not found:",
+ argp));
+ }
if (strlcpy(excbuf, cmdp, sizeof(excbuf))
>= sizeof(excbuf))