[Libvirt-cim] [PATCH 2 of 2] (#2) Fix seg fault in Virt_DevicePool - verify to be sure list is not NULL

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Oct 30 17:00:03 UTC 2009


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1256771106 25200
# Node ID 225d9f9a5cebaba93f4787558b35d6958cd2cbfb
# Parent  71465d8204cafbd92f63a1bb2f998b4df73fc156
(#2) Fix seg fault in Virt_DevicePool - verify to be sure list is not NULL

This can happen if _get_pools() is unable to connect to libvirt.

Updates:
  -Since list.cur is an unsigned int, it can't be less than 0.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 71465d8204ca -r 225d9f9a5ceb src/Virt_DevicePool.c
--- a/src/Virt_DevicePool.c	Mon Oct 26 07:47:48 2009 -0700
+++ b/src/Virt_DevicePool.c	Wed Oct 28 16:05:06 2009 -0700
@@ -1210,6 +1210,14 @@
         if (s.rc != CMPI_RC_OK)
                 goto out;
 
+        if (list.cur == 0) {
+                cu_statusf(broker, &s,
+                           CMPI_RC_ERR_NOT_FOUND,
+                           "No such instance (%s)",
+                           id);
+                goto out;
+        }
+
         *_inst = list.list[0];
 
  out:




More information about the Libvirt-cim mailing list