]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/string-util.c
Introduce free_and_strndup and use it in bus-message.c
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 9 Jul 2018 05:03:01 +0000 (07:03 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 2 Oct 2018 09:42:45 +0000 (11:42 +0200)
commit7f546026abbdc56c453a577e52d57159458c3e9c
tree47fa1d225508c78446a7651061c86dc992f66551
parent56b560c26339c4b282c06038316a91509eae75fd
Introduce free_and_strndup and use it in bus-message.c

v2: fix error in free_and_strndup()

When the orignal and copied message were the same, but shorter than specified
length l, memory read past the end of the buffer would be performed. A test
case is included: a string that had an embedded NUL ("q\0") is used to replace
"q".

v3: Fix one more bug in free_and_strndup and add tests.

v4: Some style fixed based on review, one more use of free_and_replace, and
make the tests more comprehensive.
src/basic/string-util.c
src/basic/string-util.h
src/libsystemd/sd-bus/bus-message.c
src/test/test-string-util.c
test/fuzz/fuzz-bus-message/crash-b88ad9ecf4aacf4a0caca5b5543953265367f084 [new file with mode: 0644]