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-devel

[Xen-devel] [PATCH 2/2] xl: Fix adding additional config cmdline paramet

To: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>, Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: [Xen-devel] [PATCH 2/2] xl: Fix adding additional config cmdline parameters
From: Andre Przywara <andre.przywara@xxxxxxx>
Date: Fri, 10 Sep 2010 16:15:33 +0200
Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Fri, 10 Sep 2010 07:21:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.23 (X11/20090820)
Hi,

when checking the size of the buffer we hold for additional
config parameters passed on the command line we should take the
size of the to-be-added string into account. While at it, rework
the implementation to be cleaner and safer.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

Regards,
Andre.

--
Andre Przywara
AMD-Operating System Research Center (OSRC), Dresden, Germany
Tel: +49 351 448-3567-12
commit bc37ac1bedc704293117b9e3e50f18042c4e8254
Author: Andre Przywara <andre.przywara@xxxxxxx>
Date:   Fri Sep 10 14:26:55 2010 +0200

    Improve adding additional config cmdline parameters
    
    When checking the size of the buffer we hold for additional
    config parameters passed on the command line we should take the
    size of the to-be-added string into account. While at it, rework
    the implementation to be cleaner and safer.
    
    Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>

diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index f40de2b..8fe4e08 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3251,21 +3251,17 @@ int main_create(int argc, char **argv)
         }
     }
 
-    memset(extra_config, 0, sizeof(extra_config));
-    while (optind < argc) {
-        if ((p = strchr(argv[optind], '='))) {
-            if (strlen(extra_config) + 1 < sizeof(extra_config)) {
-                if (strlen(extra_config))
-                    strcat(extra_config, "\n");
-                strcat(extra_config, argv[optind]);
-            }
+    extra_config[0] = '\0';
+    for (p = extra_config; optind < argc; optind++) {
+        if (strchr(argv[optind], '=') != NULL) {
+            p += snprintf(p, sizeof(extra_config) - (p - extra_config),
+                "%s\n", argv[optind]);
         } else if (!filename) {
             filename = argv[optind];
         } else {
             help("create");
             return 2;
         }
-        optind++;
     }
 
     memset(&dom_info, 0, sizeof(dom_info));
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/2] xl: Fix adding additional config cmdline parameters, Andre Przywara <=