[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] libxenlight: fix segfault when domid_to_name returns NULL



# 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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.