[PATCH] esx: Fix esxVI_String_Deserialize

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

 



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 |   23 +++++++++++++++++++----
 1 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c
index bcc310f..844fb65 100644
--- a/src/esx/esx_vi_types.c
+++ b/src/esx/esx_vi_types.c
@@ -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)
-- 
1.7.4.1

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