WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Fix command-line parsing in a few respects -- be more

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Fix command-line parsing in a few respects -- be more
From: Xen patchbot -3.0-testing <patchbot-3.0-testing@xxxxxxxxxxxxxxxxxxx>
Date: Sat, 22 Apr 2006 14:48:18 +0000
Delivery-date: Sat, 22 Apr 2006 07:58:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 93f0f91631240e6c8d188cd2d8876cdebb910a68
# Parent  21e5533f297a91512a2d726eac0b4f091d214a03
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 21e5533f297a -r 93f0f9163124 xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Fri Apr 21 17:52:59 2006 +0100
+++ b/xen/arch/x86/setup.c      Fri Apr 21 18:10:13 2006 +0100
@@ -161,7 +161,7 @@ void discard_initial_images(void)
 
 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;
@@ -177,7 +177,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() */
@@ -194,6 +195,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 21e5533f297a -r 93f0f9163124 xen/common/kernel.c
--- a/xen/common/kernel.c       Fri Apr 21 17:52:59 2006 +0100
+++ b/xen/common/kernel.c       Fri Apr 21 18:10:13 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

<Prev in Thread] Current Thread [Next in Thread>