[libgovirt] Fix crash on failure to parse response to an action



commit 934c8ff67296933a8da0110b472d2deb9205ad6a
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Fri Apr 25 15:28:04 2014 +0200

    Fix crash on failure to parse response to an action
    
    When a REST action fails with a 404 HTTP error (for example), the
    document we get back is not an XML document. Trying to parse it will
    return a NULL root node. If we don't return early in such a situation,
    we'll get a crash trying to dereference it later on.

 govirt/ovirt-resource.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/govirt/ovirt-resource.c b/govirt/ovirt-resource.c
index 7cd34fd..a3570fe 100644
--- a/govirt/ovirt-resource.c
+++ b/govirt/ovirt-resource.c
@@ -696,6 +696,11 @@ parse_action_response(RestProxyCall *call, OvirtResource *resource,
 
     result = FALSE;
     root = ovirt_rest_xml_node_from_call(call);
+    /* We are not guaranteed to get XML out of the call, for example we could
+     * get HTML with a 404 error */
+    if (root == NULL) {
+        return FALSE;
+    }
 
     if (g_strcmp0(root->name, "action") == 0) {
         enum OvirtResponseStatus status;


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