]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: Fix overflow in kmod_module_hex_to_str
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 8 Nov 2024 16:08:41 +0000 (17:08 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 12 Nov 2024 00:15:37 +0000 (18:15 -0600)
commitb6b27d3726ad0dcf6030dbfe2baf56e57ae490c7
treee25fb932ecdde91aaf31dd956ebe04e272166839
parent7ff978b482673533c7d048ea46cf6ce9b738df25
libkmod: Fix overflow in kmod_module_hex_to_str

If an overly long signature is found in a module file, it is possible to
trigger an out of boundary write in kmod_module_hex_to_str due to
integer and subsequent heap buffer overflow.

This approach replaces malloc + sprintf with a simple hex-lookup and a
strbuf approach, being slightly faster in real life scenarios while
adding around 100 bytes to library size. A much faster approach could be
done without strbuf and using our overflow check functions, but
readability should win here.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/236
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-module.c