[libvirt] [PATCH v2] conf: prevent crash with no uuid in cephx auth secret

Ján Tomko jtomko at redhat.com
Thu Nov 29 16:36:37 UTC 2012


Also remove the pointless check for NULL in auth.cephx.secret.uuid,
since this is a static array.
---
 src/conf/storage_conf.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c
index 3fdc5b6..99c2e52 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -458,7 +458,7 @@ virStoragePoolDefParseAuthCephx(xmlXPathContextPtr ctxt,
         return -1;
     }
 
-    if (virUUIDParse(uuid, auth->secret.uuid) < 0) {
+    if (uuid && virUUIDParse(uuid, auth->secret.uuid) < 0) {
         virReportError(VIR_ERR_XML_ERROR,
                        "%s", _("invalid auth secret uuid"));
         return -1;
@@ -979,10 +979,8 @@ virStoragePoolSourceFormat(virBufferPtr buf,
                           src->auth.cephx.username);
 
         virBufferAsprintf(buf,"      %s", "<secret");
-        if (src->auth.cephx.secret.uuid != NULL) {
-            virUUIDFormat(src->auth.cephx.secret.uuid, uuid);
-            virBufferAsprintf(buf," uuid='%s'", uuid);
-        }
+        virUUIDFormat(src->auth.cephx.secret.uuid, uuid);
+        virBufferAsprintf(buf," uuid='%s'", uuid);
 
         if (src->auth.cephx.secret.usage != NULL) {
             virBufferAsprintf(buf," usage='%s'", src->auth.cephx.secret.usage);
-- 
1.7.8.6




More information about the libvir-list mailing list