From: Emil Velikov Date: Mon, 4 Nov 2024 14:32:39 +0000 (+0000) Subject: libkmod: fix dumps for non-alias indexes X-Git-Tag: v34~137 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3d3421bce299777eeeb6ced3202602b5fc8131ac;p=thirdparty%2Fkmod.git libkmod: fix dumps for non-alias indexes For non-alias indexes prefix is an empty string, where strbuf_pushchars() returns the number of characters added to the strbuf. Since those are zero, we end up completely skipping the dump process. Cc: Tobias Stoeckmann Fixes: 889d02b1 ("libkmod: check strbuf return values") Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/224 Signed-off-by: Lucas De Marchi --- diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index 2ed8752d..9e1ba43d 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -401,7 +401,7 @@ void index_dump(struct index_file *in, int fd, const char *prefix) return; strbuf_init(&buf); - if (strbuf_pushchars(&buf, prefix)) + if (prefix[0] == '\0' || strbuf_pushchars(&buf, prefix)) index_dump_node(root, &buf, fd); strbuf_release(&buf); } @@ -866,7 +866,7 @@ void index_mm_dump(struct index_mm *idx, int fd, const char *prefix) return; strbuf_init(&buf); - if (strbuf_pushchars(&buf, prefix)) + if (prefix[0] == '\0' || strbuf_pushchars(&buf, prefix)) index_mm_dump_node(root, &buf, fd); strbuf_release(&buf); }