From: Lennart Poettering Date: Fri, 11 Nov 2022 21:04:37 +0000 (+0100) Subject: nulstr-util: use memdup_suffix0() where appropriate X-Git-Tag: v253-rc1~539^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1ef970377485499b1b62e1150fec044aa852b7a1;p=thirdparty%2Fsystemd.git nulstr-util: use memdup_suffix0() where appropriate if the nulstr is not nul-terminated, we shouldn't use strndup() but memdup_suffix0(), to not trip up static analyzers which imply we are duping a string here. --- diff --git a/src/basic/nulstr-util.c b/src/basic/nulstr-util.c index e8e5629e952..2da64fcbe99 100644 --- a/src/basic/nulstr-util.c +++ b/src/basic/nulstr-util.c @@ -37,7 +37,7 @@ char** strv_parse_nulstr(const char *s, size_t l) { e = memchr(p, 0, s + l - p); - v[i] = strndup(p, e ? e - p : s + l - p); + v[i] = memdup_suffix0(p, e ? e - p : s + l - p); if (!v[i]) return NULL;