[libvirt-glib 1/3] Fix NULL deref when an attribute cannot be found

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

 



When gvir_config_xml_get_attribute_content fails to find the
attribute that the caller is looking for, we will try to dereference
'attr' which is NULL in this case. This will cause a crash.
---
 libvirt-gconfig/libvirt-gconfig-helpers.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libvirt-gconfig/libvirt-gconfig-helpers.c b/libvirt-gconfig/libvirt-gconfig-helpers.c
index 49c7f90..3790cab 100644
--- a/libvirt-gconfig/libvirt-gconfig-helpers.c
+++ b/libvirt-gconfig/libvirt-gconfig-helpers.c
@@ -254,10 +254,10 @@ gvir_config_xml_get_attribute_content(xmlNodePtr node, const char *attr_name)
             continue;
 
         if (strcmp (attr_name, (char *)attr->name) == 0)
-            break;
+            return attr->children->content;
     }
 
-    return attr->children->content;
+    return NULL;
 }
 
 G_GNUC_INTERNAL const char *
-- 
1.7.7.6

--
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]