Skip to content

Commit 849464d

Browse files
keesmichal42
authored andcommitted
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>
1 parent 21cf6e5 commit 849464d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

scripts/mod/sumversion.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
416416
basename = strrchr(modname, '/') + 1;
417417
else
418418
basename = modname;
419-
sprintf(filelist, "%s/%.*s.mod", modverdir,
419+
snprintf(filelist, sizeof(filelist), "%s/%.*s.mod", modverdir,
420420
(int) strlen(basename) - 2, basename);
421421

422422
file = grab_file(filelist, &len);

0 commit comments

Comments
 (0)