# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 8db5ac82c20f0374fdf35eccad935d55d7edb2d9
# Parent 2b37b17cca09505bcfe8904dc8695c3b9640d1c1
Fix command-line parsing in a few respects -- be more
generous about what we accept, avoid stack overflow, and
print the command line during boot (rather useful!).
This should fix the 'lapic' and 'nolapic' boot options.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
diff -r 2b37b17cca09 -r 8db5ac82c20f xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c Fri Apr 21 18:06:06 2006 +0100
+++ b/xen/arch/x86/setup.c Fri Apr 21 18:09:32 2006 +0100
@@ -194,7 +194,7 @@ static void percpu_free_unused_areas(voi
void __init __start_xen(multiboot_info_t *mbi)
{
- char *cmdline;
+ char __cmdline[] = "", *cmdline = __cmdline;
struct domain *idle_domain;
unsigned long _initrd_start = 0, _initrd_len = 0;
unsigned int initrdidx = 1;
@@ -210,7 +210,8 @@ void __init __start_xen(multiboot_info_t
/* Parse the command-line options. */
if ( (mbi->flags & MBI_CMDLINE) && (mbi->cmdline != 0) )
- cmdline_parse(__va(mbi->cmdline));
+ cmdline = __va(mbi->cmdline);
+ cmdline_parse(cmdline);
set_current((struct vcpu *)0xfffff000); /* debug sanity */
set_processor_id(0); /* needed early, for smp_processor_id() */
@@ -227,6 +228,8 @@ void __init __start_xen(multiboot_info_t
serial_init_preirq();
init_console();
+
+ printf("Command line: %s\n", cmdline);
/* Check that we have at least one Multiboot module. */
if ( !(mbi->flags & MBI_MODULES) || (mbi->mods_count == 0) )
diff -r 2b37b17cca09 -r 8db5ac82c20f xen/common/kernel.c
--- a/xen/common/kernel.c Fri Apr 21 18:06:06 2006 +0100
+++ b/xen/common/kernel.c Fri Apr 21 18:09:32 2006 +0100
@@ -43,13 +43,19 @@ void cmdline_parse(char *cmdline)
/* Grab the next whitespace-delimited option. */
q = opt;
while ( (*p != ' ') && (*p != '\0') )
- *q++ = *p++;
+ {
+ if ( (q-opt) < (sizeof(opt)-1) ) /* avoid overflow */
+ *q++ = *p;
+ p++;
+ }
*q = '\0';
/* Search for value part of a key=value option. */
optval = strchr(opt, '=');
if ( optval != NULL )
- *optval++ = '\0';
+ *optval++ = '\0'; /* nul-terminate the option value */
+ else
+ optval = q; /* default option value is empty string */
for ( param = &__setup_start; param <= &__setup_end; param++ )
{
@@ -59,23 +65,18 @@ void cmdline_parse(char *cmdline)
switch ( param->type )
{
case OPT_STR:
- if ( optval != NULL )
- {
- strncpy(param->var, optval, param->len);
- ((char *)param->var)[param->len-1] = '\0';
- }
+ strncpy(param->var, optval, param->len);
+ ((char *)param->var)[param->len-1] = '\0';
break;
case OPT_UINT:
- if ( optval != NULL )
- *(unsigned int *)param->var =
- simple_strtol(optval, (char **)&optval, 0);
+ *(unsigned int *)param->var =
+ simple_strtol(optval, (char **)&optval, 0);
break;
case OPT_BOOL:
*(int *)param->var = 1;
break;
case OPT_CUSTOM:
- if ( optval != NULL )
- ((void (*)(char *))param->var)(optval);
+ ((void (*)(char *))param->var)(optval);
break;
}
}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|