]> git.ipfire.org Git - thirdparty/kmod.git/commit
modinfo: Prevent undefined behavior with long keys
authorTobias Stoeckmann <tobias@stoeckmann.org>
Wed, 16 Oct 2024 09:43:47 +0000 (11:43 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 17 Oct 2024 21:47:53 +0000 (16:47 -0500)
commit7b416d59e4505b8f0a59dd0111ed738b79de2629
tree04bce8cf4fa9595528a366f2a85898396df1e95f
parent136ffe757f8b39df0b6d11897db632cdad77ea87
modinfo: Prevent undefined behavior with long keys

If a key is longer than INT_MAX, it is possible to trigger a signed
integer overflow. Since this overflow only occurs for formatting,
prevent it by checking if key is longer than 15 characters. If it is,
there is no need to add any more spacing anyway.

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/184
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
tools/modinfo.c