From 36dc2e68859cd2abbc2c3cb42ddc71c921dc3a2d Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Sun, 10 May 2015 10:15:36 +0000 Subject: [PATCH] The initial logic for allocating the new string was wrong, the conversion to strndup(3) duplicated the same mistake, actually strdup(3) is good enough to allocate the new string. --- usr.sbin/pw/pw_conf.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/usr.sbin/pw/pw_conf.c b/usr.sbin/pw/pw_conf.c index 46474a121c06..e988f4bdf121 100644 --- a/usr.sbin/pw/pw_conf.c +++ b/usr.sbin/pw/pw_conf.c @@ -213,15 +213,12 @@ char * newstr(char const * p) { char *q; - size_t l; if ((p = unquote(p)) == NULL) return (NULL); - l = strlen(p) + 1; - - if ((q = strndup(p, l)) == NULL) - err(1, "strndup()"); + if ((q = strdup(p)) == NULL) + err(1, "strdup()"); return (q); }