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

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

 



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@xxxxxxxxxx>
---
 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

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]