From 9dd4acc6d35b24f7de0880e7862b46fa9f379860 Mon Sep 17 00:00:00 2001 From: Pascal Terjan Date: Mon, 10 Aug 2009 14:51:10 +0000 Subject: Avoid smashing the stack if someday a module has more than 49 dependencies --- mdk-stage1/modules.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mdk-stage1/modules.c b/mdk-stage1/modules.c index 3f88656ee..6445ead41 100644 --- a/mdk-stage1/modules.c +++ b/mdk-stage1/modules.c @@ -161,7 +161,7 @@ static int load_modules_dependencies(void) start = ptr; i = 0; - while (start && *start) { + while (start && *start && i < sizeof(tmp_deps)/sizeof(char *)) { ptr = strchr(start, ' '); if (ptr) *ptr = '\0'; tmp_deps[i++] = filename2modname(start); @@ -172,6 +172,12 @@ static int load_modules_dependencies(void) while (start && *start && *start == ' ') start++; } + if(i >= sizeof(tmp_deps)/sizeof(char *)-1) { + log_message("warning, more than %d dependencies for module %s", + sizeof(tmp_deps)/sizeof(char *)-1, + modules_deps[line].modname); + i = sizeof(tmp_deps)/sizeof(char *)-1; + } tmp_deps[i++] = NULL; modules_deps[line].deps = memdup(tmp_deps, sizeof(char *) * i); -- cgit v1.2.1