]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: strbuf_pushchars: handle pushing empty string gracefully
authorMartin Wilck <martin_wilck@gmx.de>
Fri, 15 Nov 2024 22:26:26 +0000 (23:26 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Fri, 29 Nov 2024 15:15:21 +0000 (09:15 -0600)
commit5f154ec21e0081daf8a02e3b6b1bf3836bb05801
tree60d2148c3e34cba8240b1c526e0c1acc694488e5
parent50ff74e0ba83421a5f39c184abb1a5d3fcc4d8ac
libkmod: strbuf_pushchars: handle pushing empty string gracefully

If buf->bytes, buf->used, and len are all 0, buf_grow() will do nothing,
and memcpy() willbe called with a NULL first argument. This will cause
an error because the function is annotated with __nonnull(1, 2).

Fixes: e62d8c7 ("strbuf: make strbuf_pushchars() a little less dumb")
Signed-off-by: Martin Wilck <martin_wilck@gmx.de>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/257
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
shared/strbuf.c
testsuite/test-strbuf.c