[syslinux:elflink] ldlinux: Don' t discard cmdline arguments when executing labels

syslinux-bot for Matt Fleming matt.fleming at intel.com
Thu Feb 21 06:33:05 PST 2013


Commit-ID:  ab018ba3ce947f206bda2fc3c367a7eb4504b553
Gitweb:     http://www.syslinux.org/commit/ab018ba3ce947f206bda2fc3c367a7eb4504b553
Author:     Matt Fleming <matt.fleming at intel.com>
AuthorDate: Thu, 21 Feb 2013 14:24:57 +0000
Committer:  Matt Fleming <matt.fleming at intel.com>
CommitDate: Thu, 21 Feb 2013 14:31:21 +0000

ldlinux: Don't discard cmdline arguments when executing labels

Don't throw away additional cmdline arguments when executing a
label. Append them instead. Gene Cumm reports,

  When using the CLI and calling a LABEL "mylabel", specifying
  "mylabel options" does not pass "options" through to the kernel's
  command line.

Reported-by: Gene Cumm <gene.cumm at gmail.com>
Signed-off-by: Matt Fleming <matt.fleming at intel.com>

---
 com32/elflink/ldlinux/ldlinux.c | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 92346ee..c692d75 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -154,9 +154,29 @@ __export void load_kernel(const char *command_line)
 	/* Virtual kernel? */
 	me = find_label(kernel);
 	if (me) {
-		type = parse_image_type(me->cmdline);
+		const char *args;
+		char *cmd;
+		size_t len = strlen(me->cmdline) + 1;
 
-		execute(me->cmdline, type);
+		/* Find the end of the command */
+		args = find_command(kernel);
+		while(*args && my_isspace(*args))
+			args++;
+
+		if (strlen(args))
+			len += strlen(args) + 1; /* +1 for space (' ') */
+
+		cmd = malloc(len);
+		if (!cmd)
+			goto bad_kernel;
+
+		if (strlen(args))
+			snprintf(cmd, len, "%s %s", me->cmdline, args);
+		else
+			strncpy(cmd, me->cmdline, len);
+
+		type = parse_image_type(cmd);
+		execute(cmd, type);
 		/* We shouldn't return */
 		goto bad_kernel;
 	}


More information about the Syslinux-commits mailing list