[syslinux:elflink] ldlinux: Dynamically allocate cmdline buffer to avoid overflow

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Jan 24 09:45:09 PST 2013


Commit-ID:  b1d6dbbb4cf1784ebb8dff0d772b6bc2cb5c89e3
Gitweb:     http://www.syslinux.org/commit/b1d6dbbb4cf1784ebb8dff0d772b6bc2cb5c89e3
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 24 Jan 2013 11:52:32 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 24 Jan 2013 17:22:45 +0000

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 <matt.fleming at intel.com>

---
 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 */
 }


More information about the Syslinux-commits mailing list