]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: refactor builtin module handling
authorTobias Stoeckmann <tobias@stoeckmann.org>
Tue, 17 Sep 2024 17:59:39 +0000 (19:59 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 23 Sep 2024 13:29:30 +0000 (08:29 -0500)
commit1005e99ef05a910857843a299fe9c83e26e4c74f
tree0967eb1325fe5b532cd1c04941db89894079b270
parentfb2205805d85afbfbf03747aaaa0363b8750330e
libkmod: refactor builtin module handling

Remove arbitrary limits due to file sizes (INTPR_MAX check). Reduce
amount of system calls by up to 90 % utilizing stream functions.

Also make sure that no TOCTOU could ever happen by not iterating
through the file twice: First to figure out amount of strings, then
parsing them. If the file changes in between, this can lead to
memory corruption.

Even though more memory allocations might occur due to strbuf usage,
performance generally increased by heavy reduction of system calls.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/136
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-builtin.c