From: Matt Fleming Date: Fri, 8 Apr 2011 12:15:43 +0000 (+0100) Subject: ldlinux: Pass entire cmdline to execute() X-Git-Tag: syslinux-5.00-pre1~73^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=27a4a7785bef251ab58cf99ad73e59ee838ff30b;p=platform%2Fupstream%2Fsyslinux.git ldlinux: Pass entire cmdline to execute() We need to pass the entire cmdline to execute(), not just the kernel name. execute() does all the required processing of cmdline arguments and passes them to the loader in the correct format, e.g. for COM32 modules the cmdline arguments need to be passed in the traditional char *argv[] way. So stop using strtok() which modifies its first argument and means we therefore lose the cmdline after the kernel name. Previously, the "argc" and "argv" arguments that are passed to a module's main() function contained bogus values. Signed-off-by: Matt Fleming --- diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c index 36eaded..839a28a 100644 --- a/com32/elflink/ldlinux/ldlinux.c +++ b/com32/elflink/ldlinux/ldlinux.c @@ -22,8 +22,7 @@ static void load_kernel(const char *kernel) { struct menu_entry *me; enum kernel_type type; - const char *cmdline; - char *kernel_name; + const char *cmdline, *p; int len; /* Virtual kernel? */ @@ -38,23 +37,25 @@ static void load_kernel(const char *kernel) if (!allowimplicit) goto bad_implicit; - kernel_name = strtok((char *)kernel, COMMAND_DELIM); - len = strlen(kernel_name); + /* Find the end of the command */ + while (*p && !my_isspace(*p)) + p++; - if (!strcmp(kernel_name + len - 4, ".c32")) { + len = p - kernel; + if (!strncmp(kernel + len - 4, ".c32", 4)) { type = KT_COM32; - } else if (!strcmp(kernel_name + len - 2, ".0")) { + } else if (!strncmp(kernel + len - 2, ".0", 2)) { type = KT_PXE; - } else if (!strcmp(kernel_name + len - 3, ".bs")) { + } else if (!strncmp(kernel + len - 3, ".bs", 3)) { type = KT_BOOT; - } else if (!strcmp(kernel_name + len - 4, ".img")) { + } else if (!strncmp(kernel + len - 4, ".img", 4)) { type = KT_FDIMAGE; - } else if (!strcmp(kernel_name + len - 4, ".bin")) { + } else if (!strncmp(kernel + len - 4, ".bin", 4)) { type = KT_BOOT; - } else if (!strcmp(kernel_name + len - 4, ".bss")) { + } else if (!strncmp(kernel + len - 4, ".bss", 4)) { type = KT_BSS; - } else if (!strcmp(kernel_name + len - 4, ".com") - || !strcmp(kernel_name + len - 4, ".cbt")) { + } else if (!strncmp(kernel + len - 4, ".com", 4) || + !strncmp(kernel + len - 4, ".cbt", 4)) { type = KT_COMBOOT; } /* use KT_KERNEL as default */