1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

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.
This commit is contained in:
Lennart Poettering 2022-11-11 22:04:37 +01:00 committed by Yu Watanabe
parent eecac5053b
commit 1ef9703774

View File

@ -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;