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

[libvirt] [PATCH] virDomainMemoryStats: avoid null dereference



* src/libvirt.c (virDomainMemoryStats): Check domain before flags.
---

Another valid bug found by clang.  User's generally should't call
virDomainMemoryStats(NULL,...), but we don't forbid it elsewhere, and
doing so is not supposed to crash libvirt.  All other flags checks in
this file occur after validating the object first.

 src/libvirt.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 479a9b5..f65cc24 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4411,12 +4411,6 @@ int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats,

     VIR_DOMAIN_DEBUG(dom, "stats=%p, nr_stats=%u", stats, nr_stats);

-    if (flags != 0) {
-        virLibDomainError(VIR_ERR_INVALID_ARG,
-                           _("flags must be zero"));
-        goto error;
-    }
-
     virResetLastError();

     if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
@@ -4424,6 +4418,12 @@ int virDomainMemoryStats (virDomainPtr dom, virDomainMemoryStatPtr stats,
         virDispatchError(NULL);
         return -1;
     }
+    if (flags != 0) {
+        virLibDomainError(VIR_ERR_INVALID_ARG,
+                           _("flags must be zero"));
+        goto error;
+    }
+
     if (!stats || nr_stats == 0)
         return 0;

-- 
1.7.4


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