summaryrefslogtreecommitdiff
path: root/usr.sbin/eigrpd
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/eigrpd
parent739a057e53d34ec7f29d9c618ed3468cc6fba984 (diff)
replace malloc()+strlcpy() with strndup() in cmdline_symset().
"looks good" gilles@ halex@
Diffstat (limited to 'usr.sbin/eigrpd')
-rw-r--r--usr.sbin/eigrpd/parse.y13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.sbin/eigrpd/parse.y b/usr.sbin/eigrpd/parse.y
index eedb3a7e162..1bb69f092c5 100644
--- a/usr.sbin/eigrpd/parse.y
+++ b/usr.sbin/eigrpd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.27 2018/07/11 07:39:22 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.28 2018/09/07 07:35:30 miko Exp $ */
/*
* Copyright (c) 2015 Renato Westphal <renato@openbsd.org>
@@ -1094,17 +1094,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);