aboutsummaryrefslogtreecommitdiffstats
path: root/xen/common/kernel.c
diff options
context:
space:
mode:
authorkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-04-21 18:09:32 +0100
committerkaf24@firebug.cl.cam.ac.uk <kaf24@firebug.cl.cam.ac.uk>2006-04-21 18:09:32 +0100
commitb07b5dcc56bb6bacd55fb7d65ac854ee62680460 (patch)
treeb6c5670ed48393fdc6496f7dc75675af314c3fcf /xen/common/kernel.c
parenta3fd8815ef4c686ae44e9792933e4941896a6977 (diff)
downloadxen-b07b5dcc56bb6bacd55fb7d65ac854ee62680460.tar.gz
xen-b07b5dcc56bb6bacd55fb7d65ac854ee62680460.tar.bz2
xen-b07b5dcc56bb6bacd55fb7d65ac854ee62680460.zip
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@xensource.com>
Diffstat (limited to 'xen/common/kernel.c')
-rw-r--r--xen/common/kernel.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f7dffadd69..35fe07feb3 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -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;
}
}