[libvirt] [PATCH] xend_internal.c: don't dereference NULL for unexpected input

Jim Meyering jim at meyering.net
Fri Feb 19 16:47:08 UTC 2010


My recent xend_internal.c change introduced a bug.
"val" could be NULL just before the STREQ comparisons.
Here's a fix:

>From 5cc834ab30a444cc35ddc9317379f4be3b5cf4c5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering at redhat.com>
Date: Fri, 19 Feb 2010 17:45:41 +0100
Subject: [PATCH] xend_internal.c: don't dereference NULL for unexpected input

* src/xen/xend_internal.c (xenDaemonDomainSetAutostart): Avoid a NULL
dereference upon non-SEXPR_VALUE'd on_xend_start.  This bug was
introduced by commit 37ce5600c0bb1aed9e2f2888922388de4340ebd3.
---
 src/xen/xend_internal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 1f8b106..9d95291 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -4411,7 +4411,7 @@ xenDaemonDomainSetAutostart(virDomainPtr domain,
     if (autonode) {
         const char *val = (autonode->u.s.car->kind == SEXPR_VALUE
                            ? autonode->u.s.car->u.value : NULL);
-        if (!STREQ(val, "ignore") && !STREQ(val, "start")) {
+        if (!val || (!STREQ(val, "ignore") && !STREQ(val, "start"))) {
             virXendError(domain->conn, VIR_ERR_INTERNAL_ERROR,
                          "%s", _("unexpected value from on_xend_start"));
             goto error;
--
1.7.0.233.g05e1a




More information about the libvir-list mailing list