[libvirt] [PATCH 2/7] conf: prevent crash with no uuid in cephx auth secret

Ján Tomko jtomko at redhat.com
Wed Nov 28 13:34:46 UTC 2012


Also remove the pointles 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 1c9934c..5a2cf1b 100644
--- a/src/conf/storage_conf.c
+++ b/src/conf/storage_conf.c
@@ -452,7 +452,7 @@ virStoragePoolDefParseAuthCephx(xmlXPathContextPtr ctxt,
 
     uuid = virXPathString("string(./auth/secret/@uuid)", ctxt);
     auth->secret.usage = virXPathString("string(./auth/secret/@usage)", ctxt);
-    if (uuid == NULL && auth->secret.usage == NULL) {
+    if (uuid == NULL || auth->secret.usage == NULL) {
         virReportError(VIR_ERR_XML_ERROR, "%s",
                        _("missing auth secret uuid or usage attribute"));
         return -1;
@@ -976,10 +976,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