Skip to content

Commit

Permalink
kbuild: do not segfault in modpost if MODVERDIR is not defined
Browse files Browse the repository at this point in the history
A combination of calling modpost with option -a and MODVERDIR undefined
caused segmentation fault. So provide a default value and accept the
error messages it generates instead.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
  • Loading branch information
Sam Ravnborg committed Feb 19, 2006
1 parent 9d6e7a7 commit 41370d3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/mod/sumversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,19 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
struct md4_ctx md;
char *sources, *end, *fname;
const char *basename;
char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
char filelist[PATH_MAX + 1];
char *modverdir = getenv("MODVERDIR");

if (!modverdir)
modverdir = ".";

/* Source files for module are in .tmp_versions/modname.mod,
after the first line. */
if (strrchr(modname, '/'))
basename = strrchr(modname, '/') + 1;
else
basename = modname;
sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"),
sprintf(filelist, "%s/%.*s.mod", modverdir,
(int) strlen(basename) - 2, basename);

file = grab_file(filelist, &len);
Expand Down

0 comments on commit 41370d3

Please sign in to comment.