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] [xen-unstable] xl: fix adding configuration parameters o

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xl: fix adding configuration parameters on command line
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 10 Sep 2010 14:40:43 -0700
Delivery-date: Fri, 10 Sep 2010 14:44:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 Andre Przywara <andre.przywara@xxxxxxx>
# Date 1284141448 -3600
# Node ID a9f272d4ab4f121e223b9533b5c9d3489f733597
# Parent  5ad5ba05e3aff5ed78bb225755850d760866b178
xl: fix adding configuration parameters on command line

Since we read the text file as is from the disk, there is no
trailing \0 at the end terminating the C string. Therefore we
must not use strcat to this buffer. Also we need to allocate
space for the trailing zero byte.

Signed-off-by: Andre Przywara <andre.przywara@xxxxxxx>
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 tools/libxl/xl_cmdimpl.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff -r 5ad5ba05e3af -r a9f272d4ab4f tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Fri Sep 10 18:49:49 2010 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Fri Sep 10 18:57:28 2010 +0100
@@ -1315,22 +1315,20 @@ static int create_domain(struct domain_c
                                        &config_data, &config_len);
         if (ret) { fprintf(stderr, "Failed to read config file: %s: %s\n",
                            config_file, strerror(errno)); return ERROR_FAIL; }
-        if (!restore_file && extra_config
-            && strlen(extra_config)) {
-            if (config_len > INT_MAX - (strlen(extra_config) + 2)) {
+        if (!restore_file && extra_config && strlen(extra_config)) {
+            if (config_len > INT_MAX - (strlen(extra_config) + 2 + 1)) {
                 fprintf(stderr, "Failed to attach extra configration\n");
                 return ERROR_FAIL;
             }
+            /* allocate space for the extra config plus two EOLs plus \0 */
             config_data = realloc(config_data, config_len
-                + strlen(extra_config) + 2);
+                + strlen(extra_config) + 2 + 1);
             if (!config_data) {
                 fprintf(stderr, "Failed to realloc config_data\n");
                 return ERROR_FAIL;
             }
-            strcat(config_data, "\n");
-            strcat(config_data, extra_config);
-            strcat(config_data, "\n");
-            config_len += (strlen(extra_config) + 2);
+            config_len += sprintf(config_data + config_len, "\n%s\n",
+                extra_config);
         }
     } else {
         if (!config_data) {

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xl: fix adding configuration parameters on command line, Xen patchbot-unstable <=