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] libxenlight: fix segfault when domid_to_n

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libxenlight: fix segfault when domid_to_name returns NULL
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 15 Mar 2010 06:35:13 -0700
Delivery-date: Mon, 15 Mar 2010 06:35:48 -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 Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1268659326 0
# Node ID a6ed354be9e3eb2d6e8610127789d4c7cffe05b8
# Parent  c56b885e7debd08169fb67b90278dd1c9cee8ad4
libxenlight: fix segfault when domid_to_name returns NULL

The function libxl_domid_to_name() can return NULL if the path
/local/domain/%d/name does not exist.  This causes a segfault if the
NULL name is later passed as a value to libxl_xs_writev().  I'm
hitting this making a call to libxl_device_vfb_add() from my graphical
switcher application.

This patch modifies xs_writev() and libxl_xs_writev() to skip NULL
values.

Signed-off-by: Eamon Walsh <ewalsh@xxxxxxxxxxxxx>
---
 tools/libxl/libxl_xshelp.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff -r c56b885e7deb -r a6ed354be9e3 tools/libxl/libxl_xshelp.c
--- a/tools/libxl/libxl_xshelp.c        Mon Mar 15 13:19:16 2010 +0000
+++ b/tools/libxl/libxl_xshelp.c        Mon Mar 15 13:22:06 2010 +0000
@@ -33,11 +33,11 @@ int xs_writev(struct xs_handle *xsh, xs_
 
     for (i = 0; kvs[i] != NULL; i += 2) {
         asprintf(&path, "%s/%s", dir, kvs[i]);
-        if (path) {
+        if (path && kvs[i + 1]) {
             int length = strlen(kvs[i + 1]);
             xs_write(xsh, t, path, kvs[i + 1], length);
-            free(path);
         }
+        free(path);
     }
     return 0;
 }
@@ -74,7 +74,7 @@ int libxl_xs_writev(struct libxl_ctx *ct
 
     for (i = 0; kvs[i] != NULL; i += 2) {
         path = libxl_sprintf(ctx, "%s/%s", dir, kvs[i]);
-        if (path) {
+        if (path && kvs[i + 1]) {
             int length = strlen(kvs[i + 1]);
             xs_write(ctx->xsh, t, path, kvs[i + 1], length);
         }

_______________________________________________
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] libxenlight: fix segfault when domid_to_name returns NULL, Xen patchbot-unstable <=