From d67cef2425fb5e75b75d52d9a308da6d29cd7a0d Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 13 Jun 2007 06:47:47 +0000 Subject: hush: fix read builtin to not read ahead past eol and to not use insane amounts of stack. Testsuite updated. --- modutils/insmod.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'modutils/insmod.c') diff --git a/modutils/insmod.c b/modutils/insmod.c index a81ca7fba..b9d8a0243 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c @@ -4262,6 +4262,7 @@ int insmod_ng_main(int argc, char **argv) { long ret; size_t len; + int optlen; void *map; char *filename, *options; @@ -4270,12 +4271,12 @@ int insmod_ng_main(int argc, char **argv) bb_show_usage(); /* Rest is options */ - options = xstrdup(""); + options = xzalloc(1); + optlen = 0; while (*++argv) { - int optlen = strlen(options); options = xrealloc(options, optlen + 2 + strlen(*argv) + 2); /* Spaces handled by "" pairs, but no way of escaping quotes */ - sprintf(options + optlen, (strchr(*argv,' ') ? "\"%s\" " : "%s "), *argv); + optlen += sprintf(options + optlen, (strchr(*argv,' ') ? "\"%s\" " : "%s "), *argv); } #if 0 -- cgit v1.2.3-55-g6feb