]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: return ENOMEM when strbuf_pushchar(s) fails
authorEmil Velikov <emil.l.velikov@gmail.com>
Wed, 4 Jun 2025 16:16:25 +0000 (17:16 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 11 Jun 2025 13:05:06 +0000 (08:05 -0500)
commit180335d11ce9e18d1e46dce71d8cee22a842703a
treeec4ad2b8a14dbfe509c9ad4549732c8f5ddd8972
parent6047d8b9f541464dd27631563938fe9bdbf4b968
libkmod: return ENOMEM when strbuf_pushchar(s) fails

Currently get_strings() assumes that errno is set when either function
fails. This is not the case when our overflow checks kick in. The other
case where these functions fail is memory exhaustion.

In practice we cannot do anything if either of those trigger, plus I
don't see a compelling reason to set errno to EOVERFLOW... Something
which other parts of the codebase don't do.

So let's just return ENOMEM and avoid the corner case of returning
success from get_strings(), when it should be failing.

Fixes: 1005e99e ("libkmod: refactor builtin module handling")
Fixes: 952bf223 ("strbuf: Add strbuf_reserve_extra()")
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/368
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
(cherry picked from commit 1eeb00f776eb9f78c4ec06f7891ce602cafb619e)
libkmod/libkmod-builtin.c