Skip to content

Commit

Permalink
kbuild: replace unbounded sprintf call in modpost
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
kees authored and michal42 committed Nov 6, 2013
1 parent 21cf6e5 commit 849464d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/mod/sumversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 849464d

Please sign in to comment.