[libvirt] [PATCH] Fix segfault if storage pool has no type attribute (possibly others)

Cole Robinson crobinso at redhat.com
Fri Jun 19 16:36:51 UTC 2009


virEnumFromString doesn't check for a NULL string, and will segfault if
passed one. Lots of calling code protects against this, but at least
/pool/@type parsing does not.

Signed-off-by: Cole Robinson <crobinso at redhat.com>
---
 src/util.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/util.c b/src/util.c
index d8ab37f..8b746f5 100644
--- a/src/util.c
+++ b/src/util.c
@@ -1622,6 +1622,9 @@ int virEnumFromString(const char *const*types,
                       const char *type)
 {
     unsigned int i;
+    if (!type)
+        return -1;
+
     for (i = 0 ; i < ntypes ; i++)
         if (STREQ(types[i], type))
             return i;
-- 
1.6.3.2




More information about the libvir-list mailing list