summaryrefslogtreecommitdiff
path: root/usr.sbin/ldpd/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/ldpd/parse.y
parent739a057e53d34ec7f29d9c618ed3468cc6fba984 (diff)
replace malloc()+strlcpy() with strndup() in cmdline_symset().
"looks good" gilles@ halex@
Diffstat (limited to 'usr.sbin/ldpd/parse.y')
-rw-r--r--usr.sbin/ldpd/parse.y13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y
index cc70041d4d9..5197bb0c368 100644
--- a/usr.sbin/ldpd/parse.y
+++ b/usr.sbin/ldpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.65 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.66 2018/09/07 07:35:31 miko Exp $ */
/*
* Copyright (c) 2013, 2015, 2016 Renato Westphal <renato@openbsd.org>
@@ -1317,17 +1317,12 @@ cmdline_symset(char *s)
{
char *sym, *val;
int ret;
- size_t len;
if ((val = strrchr(s, '=')) == NULL)
return (-1);
-
- len = strlen(s) - strlen(val) + 1;
- if ((sym = malloc(len)) == NULL)
- errx(1, "cmdline_symset: malloc");
-
- strlcpy(sym, s, len);
-
+ sym = strndup(s, val - s);
+ if (sym == NULL)
+ errx(1, "%s: strndup", __func__);
ret = symset(sym, val + 1, 1);
free(sym);