ldlinux: Dynamically allocate cmdline buffer to avoid overflow
authorMatt Fleming <matt.fleming@intel.com>
Thu, 24 Jan 2013 11:52:32 +0000 (11:52 +0000)
committerMatt Fleming <matt.fleming@intel.com>
Thu, 24 Jan 2013 17:22:45 +0000 (17:22 +0000)
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 <matt.fleming@intel.com>
com32/elflink/ldlinux/execute.c

index 727df50..5c53b99 100644 (file)
@@ -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 */
 }