mirror of
https://git.kernel.org/pub/scm/utils/kernel/kmod/kmod.git
synced 2024-11-26 21:33:42 +08:00
libkmod: Prevent ouf of boundary access
Do not access memory out of bounds if the first character read by fgets is NUL. Treat such a character as EOL instead. This is a purely defensive measure since /proc/modules should normaly not contain such characters. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org> Link: https://github.com/kmod-project/kmod/pull/227 Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
This commit is contained in:
parent
6bd8c2bc7b
commit
aad7c6973b
@ -1382,7 +1382,7 @@ KMOD_EXPORT int kmod_module_new_from_loaded(struct kmod_ctx *ctx, struct kmod_li
|
||||
kmod_module_unref(m);
|
||||
}
|
||||
eat_line:
|
||||
while (line[len - 1] != '\n' && fgets(line, sizeof(line), fp))
|
||||
while (len > 0 && line[len - 1] != '\n' && fgets(line, sizeof(line), fp))
|
||||
len = strlen(line);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user