projects
/
systemd
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
eecac50
)
nulstr-util: use memdup_suffix0() where appropriate
author
Lennart Poettering
<lennart@poettering.net>
Fri, 11 Nov 2022 21:04:37 +0000
(22:04 +0100)
committer
Yu Watanabe
<watanabe.yu+github@gmail.com>
Sun, 13 Nov 2022 08:39:08 +0000
(17:39 +0900)
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
patch
|
blob
|
history
diff --git
a/src/basic/nulstr-util.c
b/src/basic/nulstr-util.c
index e8e5629e95296215a19b5c607b84a1a1cc82eb73..2da64fcbe9909c18a4e585efcaa72a7e75e7ff61 100644
(file)
--- 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;