diff options
author | miko <miko@openbsd.org> | 2018-09-07 07:35:30 +0000 |
---|---|---|
committer | miko <miko@openbsd.org> | 2018-09-07 07:35:30 +0000 |
commit | ed1b9eb881714d81d85f14afa35f51254e80d5b6 (patch) | |
tree | a7e9c90d1e807274ba7f0b178c37c63c7b6aea46 /usr.sbin/httpd | |
parent | Fix "_nfiles" reference for crash dump. (diff) | |
download | wireguard-openbsd-ed1b9eb881714d81d85f14afa35f51254e80d5b6.tar.xz wireguard-openbsd-ed1b9eb881714d81d85f14afa35f51254e80d5b6.zip |
replace malloc()+strlcpy() with strndup() in cmdline_symset().
"looks good" gilles@ halex@
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r-- | usr.sbin/httpd/parse.y | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.sbin/httpd/parse.y b/usr.sbin/httpd/parse.y index 962af87ffc2..4851182f5cd 100644 --- a/usr.sbin/httpd/parse.y +++ b/usr.sbin/httpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.105 2018/07/11 07:39:22 krw Exp $ */ +/* $OpenBSD: parse.y,v 1.106 2018/09/07 07:35:30 miko Exp $ */ /* * Copyright (c) 2007 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -1819,17 +1819,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); |