Skip to content

Commit 41370d3

Browse files
author
Sam Ravnborg
committed
kbuild: do not segfault in modpost if MODVERDIR is not defined
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>
1 parent 9d6e7a7 commit 41370d3

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎scripts/mod/sumversion.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,19 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
381381
struct md4_ctx md;
382382
char *sources, *end, *fname;
383383
const char *basename;
384-
char filelist[strlen(getenv("MODVERDIR")) + strlen("/") +
385-
strlen(modname) - strlen(".o") + strlen(".mod") + 1 ];
384+
char filelist[PATH_MAX + 1];
385+
char *modverdir = getenv("MODVERDIR");
386+
387+
if (!modverdir)
388+
modverdir = ".";
386389

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

396399
file = grab_file(filelist, &len);

0 commit comments

Comments
 (0)