[libgovirt] Fix potential segfault on malformed XML
- From: Christophe Fergeau <teuf src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgovirt] Fix potential segfault on malformed XML
- Date: Thu, 9 Oct 2014 13:37:56 +0000 (UTC)
commit 5e0f8ccb3733a89c1aba4eaaac3c743dc46716f2
Author: Christophe Fergeau <cfergeau redhat com>
Date: Thu Oct 9 15:29:01 2014 +0200
Fix potential segfault on malformed XML
ovirt_resource_set_{actions,sub_collections}_from_xml warn if
link_node->name is NULL, but then call strcmp() on it anyway, which
would cause a crash. Use g_strcpm0() instead to avoid the crash.
The rest of the code will safely handle a NULL link_node->name.
This issue was reported by Coverity.
govirt/ovirt-resource.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index a6eb026..cfecc96 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -330,7 +330,7 @@ ovirt_resource_set_actions_from_xml(OvirtResource *resource, RestXmlNode *node)
g_warn_if_fail(link_node != NULL);
g_warn_if_fail(link_node->name != NULL);
- g_warn_if_fail(strcmp(link_node->name, "link") == 0);
+ g_warn_if_fail(g_strcmp0(link_node->name, "link") == 0);
link_name = rest_xml_node_get_attr(link_node, "rel");
href = rest_xml_node_get_attr(link_node, "href");
@@ -360,7 +360,7 @@ ovirt_resource_set_sub_collections_from_xml(OvirtResource *resource,
g_warn_if_fail(link_node != NULL);
g_warn_if_fail(link_node->name != NULL);
- g_warn_if_fail(strcmp(link_node->name, "link") == 0);
+ g_warn_if_fail(g_strcmp0(link_node->name, "link") == 0);
link_name = rest_xml_node_get_attr(link_node, "rel");
href = rest_xml_node_get_attr(link_node, "href");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]