From: Kees Cook Date: Fri, 25 Oct 2013 13:14:43 +0000 (-0700) Subject: kbuild: replace unbounded sprintf call in modpost X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=849464d1ba97a13b388fee9a69fbbeee175b349c;p=openwrt%2Fstaging%2Fblogic.git 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 Signed-off-by: Michal Marek --- diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 9dfcd6d988da..deb2994b04c4 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -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);