summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMark Lumsden <lum@cvs.openbsd.org>2021-02-24 14:17:19 +0000
committerMark Lumsden <lum@cvs.openbsd.org>2021-02-24 14:17:19 +0000
commit54e5300719466574670527cb62f3638ae6d774aa (patch)
tree3c27582df238127b6493dfd386db42306d613cc7 /usr.bin
parent2a8f9a0c64105a84aade2ab4eafe43f9df9b3190 (diff)
Various fixes from emails Joachim Nilsson sent to tech@ many moons
ago. Sorry for the delay. - Make sure we don't deref NULL ptr in skipwhite() - Only deref vendp if not NULL - Strings must be at least 2 chars for terminating NUL character
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/mg/interpreter.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/usr.bin/mg/interpreter.c b/usr.bin/mg/interpreter.c
index 6c954d30a75..6c338766298 100644
--- a/usr.bin/mg/interpreter.c
+++ b/usr.bin/mg/interpreter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interpreter.c,v 1.5 2019/07/20 11:06:33 lum Exp $ */
+/* $OpenBSD: interpreter.c,v 1.6 2021/02/24 14:17:18 lum Exp $ */
/*
* This file is in the public domain.
*
@@ -138,7 +138,10 @@ multiarg(char *funstr)
return (dobeep_msgs("Command takes no arguments: ", cmdp));
/* now find the first argument */
- p = fendp + 1;
+ if (fendp)
+ p = fendp + 1;
+ else
+ p = "";
p = skipwhite(p);
if (strlcpy(argbuf, p, sizeof(argbuf)) >= sizeof(argbuf))
return (dobeep_msg("strlcpy error"));
@@ -268,7 +271,7 @@ static int
foundlist(char *defstr)
{
struct varentry *vt, *v1 = NULL;
- const char e[1] = "e", t[1] = "t";
+ const char e[2] = "e", t[2] = "t";
char *p, *vnamep, *vendp = NULL, *valp, *o;
int spc;
@@ -336,7 +339,9 @@ foundlist(char *defstr)
spc = 0;
}
}
- *vendp = '\0';
+ if (vendp)
+ *vendp = '\0';
+
if ((v1->vals = strndup(valp, BUFSIZE)) == NULL)
return(dobeep_msg("strndup error"));