From b1d6dbbb4cf1784ebb8dff0d772b6bc2cb5c89e3 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Thu, 24 Jan 2013 11:52:32 +0000 Subject: [PATCH] ldlinux: Dynamically allocate cmdline buffer to avoid overflow Also, because we no longer pass the allocated buffer to __intcall() and friends we can use malloc() instead of lmalloc(), leaving precious low memory for other users. Signed-off-by: Matt Fleming --- com32/elflink/ldlinux/execute.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c index 727df50..5c53b99 100644 --- a/com32/elflink/ldlinux/execute.c +++ b/com32/elflink/ldlinux/execute.c @@ -55,11 +55,9 @@ __export void execute(const char *cmdline, uint32_t type) memset(&ireg, 0, sizeof ireg); - /* for parameter will be passed to __intcall, we need use - * lmalloc a block of low memory */ - q = lmalloc(128); + q = malloc(strlen(cmdline) + 2); if (!q) { - printf("%s(): Fail to lmalloc a buffer to exec %s\n", + printf("%s(): Fail to malloc a buffer to exec %s\n", __func__, cmdline); return; } @@ -147,7 +145,7 @@ __export void execute(const char *cmdline, uint32_t type) new_linux_kernel((char *)kernel, (char *)cmdline); } - lfree((void *)kernel); + free((void *)kernel); /* If this returns, something went bad; return to menu */ } -- 2.7.4