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