summaryrefslogtreecommitdiff
path: root/usr.sbin/vmd/parse.y
diff options
context:
space:
mode:
authormiko <miko@cvs.openbsd.org>2018-09-07 07:35:32 +0000
committermiko <miko@cvs.openbsd.org>2018-09-07 07:35:32 +0000
commit8352fea9aa07e9a18a6520c91820925a43f28566 (patch)
tree59e950639558ba5ddd2f65fb58ef1f2f553a52a1 /usr.sbin/vmd/parse.y
parent739a057e53d34ec7f29d9c618ed3468cc6fba984 (diff)
replace malloc()+strlcpy() with strndup() in cmdline_symset().
"looks good" gilles@ halex@
Diffstat (limited to 'usr.sbin/vmd/parse.y')
-rw-r--r--usr.sbin/vmd/parse.y13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.sbin/vmd/parse.y b/usr.sbin/vmd/parse.y
index 2b159d9b866..13cb3e3ce3f 100644
--- a/usr.sbin/vmd/parse.y
+++ b/usr.sbin/vmd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.42 2018/07/13 08:42:49 reyk Exp $ */
+/* $OpenBSD: parse.y,v 1.43 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org>
@@ -1154,17 +1154,12 @@ cmdline_symset(char *s)
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = (val - s) + 1;
- if ((sym = malloc(len)) == NULL)
- fatal("cmdline_symset: malloc");
-
- (void)strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ fatal("%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);