]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
esx: Fix esxVI_String_Deserialize
authorMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 18 Jul 2012 22:46:21 +0000 (00:46 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Wed, 18 Jul 2012 23:31:32 +0000 (01:31 +0200)
It was broken since forever as it expected a libxml2
XML_ELEMENT_NODE containing a XML_TEXT_NODE instead of
just a XML_TEXT_NODE.

This problem was not discovered for so long because
esxVI_String_Deserialize was not used until now.

Reported by Ata Bohra

src/esx/esx_vi_types.c

index bcc310fc201f45dab046a553bde42261aaf62b52..844fb65e713a476dcab9c8550d4342deedb56945 100644 (file)
@@ -1227,11 +1227,26 @@ esxVI_String_SerializeValue(const char *value, const char *element,
     return 0;
 }
 
-/* esxVI_String_Deserialize */
-ESX_VI__TEMPLATE__DESERIALIZE(String,
+int
+esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string)
 {
-    ESX_VI__TEMPLATE__PROPERTY__DESERIALIZE_VALUE(String, value)
-})
+    if (string == NULL || *string != NULL) {
+        ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+        return -1;
+    }
+
+    if (esxVI_String_Alloc(string) < 0 ||
+        esxVI_String_DeserializeValue(node, &(*string)->value) < 0) {
+        goto failure;
+    }
+
+    return 0;
+
+  failure:
+    esxVI_String_Free(string);
+
+    return -1;
+}
 
 /* esxVI_String_DeserializeList */
 ESX_VI__TEMPLATE__LIST__DESERIALIZE(String)