]> xenbits.xensource.com Git - libvirt.git/commitdiff
storage: fix crash in luks encrypted volume creation
authorKaterina Koukiou <kkoukiou@redhat.com>
Wed, 6 Jun 2018 14:15:19 +0000 (16:15 +0200)
committerKaterina Koukiou <kkoukiou@redhat.com>
Wed, 6 Jun 2018 16:02:59 +0000 (18:02 +0200)
Fix the case when creating a luks encrypted volume
via an xml file without 'secret' element.
libvirtd was receiving SIGSEGV, now proper error is reported for
the missing element.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1468422

Signed-off-by: Katerina Koukiou <kkoukiou@redhat.com>
src/storage/storage_util.c

index 554fc757ed84ea11783ee244bb75d96fb18d49a8..87f2115869e9274e457d52c72030dd08f4f0f01d 100644 (file)
@@ -1277,6 +1277,13 @@ storageBackendCreateQemuImgSecretPath(virStoragePoolObjPtr pool,
         return NULL;
     }
 
+    if (enc->nsecrets != 1) {
+        virReportError(VIR_ERR_INVALID_ARG, "%s",
+                       _("A single <secret type='passphrase'...> "
+                         "element is expected in encryption description"));
+        return NULL;
+    }
+
     conn = virGetConnectSecret();
     if (!conn)
         return NULL;