mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-25 21:24:08 +08:00
kbuild: replace unbounded sprintf call in modpost
The modpost tool could overflow its stack buffer if someone was running with an insane shell environment. Regardless, it's technically a bug, so this fixes it to truncate the string instead of seg-faulting. Found by Coverity. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Michal Marek <mmarek@suse.cz>
This commit is contained in:
parent
21cf6e584c
commit
849464d1ba
@ -416,7 +416,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
|
||||
basename = strrchr(modname, '/') + 1;
|
||||
else
|
||||
basename = modname;
|
||||
sprintf(filelist, "%s/%.*s.mod", modverdir,
|
||||
snprintf(filelist, sizeof(filelist), "%s/%.*s.mod", modverdir,
|
||||
(int) strlen(basename) - 2, basename);
|
||||
|
||||
file = grab_file(filelist, &len);
|
||||
|
Loading…
Reference in New Issue
Block a user