From ed1b9eb881714d81d85f14afa35f51254e80d5b6 Mon Sep 17 00:00:00 2001 From: miko Date: Fri, 7 Sep 2018 07:35:30 +0000 Subject: replace malloc()+strlcpy() with strndup() in cmdline_symset(). "looks good" gilles@ halex@ --- usr.sbin/httpd/parse.y | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'usr.sbin/httpd') 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 @@ -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); -- cgit v1.2.3-59-g8ed1b