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

[libvirt] [PATCH] remote_internal.c: don't dereference a NULL "conn"



Here's the test just before the else-if in the patch below:

    if (conn &&
        conn->driver &&
        STREQ (conn->driver->name, "remote")) {

So, in the else-branch, "conn" is guaranteed to be NULL.
And dereferenced.

This may be only a theoretical risk, but if so,
the test of "conn" above should be changed to an assertion,
and/or the parameter should get the nonnull attribute.

>From a1b1d36d96f6b50ddf514539af85da20ca671bf5 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Wed, 2 Sep 2009 11:54:38 +0200
Subject: [PATCH] remote_internal.c: don't dereference a NULL "conn"

* src/remote_internal.c (remoteDevMonOpen): Avoid NULL-dereference.
---
 src/remote_internal.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/remote_internal.c b/src/remote_internal.c
index ea50c11..141fef9 100644
--- a/src/remote_internal.c
+++ b/src/remote_internal.c
@@ -5148,7 +5148,7 @@ remoteDevMonOpen(virConnectPtr conn,
         conn->devMonPrivateData = priv;
         remoteDriverUnlock(priv);
         return VIR_DRV_OPEN_SUCCESS;
-    } else if (conn->networkDriver &&
+    } else if (conn && conn->networkDriver &&
                STREQ (conn->networkDriver->name, "remote")) {
         struct private_data *priv = conn->networkPrivateData;
         remoteDriverLock(priv);
--
1.6.4.2.395.ge3d52


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