summaryrefslogtreecommitdiff
path: root/usr.sbin/switchd
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/switchd
parent739a057e53d34ec7f29d9c618ed3468cc6fba984 (diff)
replace malloc()+strlcpy() with strndup() in cmdline_symset().
"looks good" gilles@ halex@
Diffstat (limited to 'usr.sbin/switchd')
-rw-r--r--usr.sbin/switchd/parse.y13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.sbin/switchd/parse.y b/usr.sbin/switchd/parse.y
index 81ab0dafd81..191e720e3a7 100644
--- a/usr.sbin/switchd/parse.y
+++ b/usr.sbin/switchd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.10 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.11 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2007-2016 Reyk Floeter <reyk@openbsd.org>
@@ -705,17 +705,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);