From 1ef970377485499b1b62e1150fec044aa852b7a1 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 11 Nov 2022 22:04:37 +0100 Subject: [PATCH] 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. --- src/basic/nulstr-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/nulstr-util.c b/src/basic/nulstr-util.c index e8e5629e95..2da64fcbe9 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; -- 2.25.1