render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
fbe740
From 914a920180c9803a57c06bd71f5270724c1dc900 Mon Sep 17 00:00:00 2001
fbe740
Message-Id: <914a920180c9803a57c06bd71f5270724c1dc900@dist-git>
fbe740
From: Peter Krempa <pkrempa@redhat.com>
fbe740
Date: Fri, 20 Mar 2020 10:28:52 +0100
fbe740
Subject: [PATCH] virStorageEncryptionSecretCopy: Properly copy internals
fbe740
MIME-Version: 1.0
fbe740
Content-Type: text/plain; charset=UTF-8
fbe740
Content-Transfer-Encoding: 8bit
fbe740
fbe740
virStorageEncryptionSecretPtr may have a string inside it, thus we must
fbe740
copy the string too. Use virSecretLookupDefCopy to do that.
fbe740
fbe740
Caused by non-obvious code introduced in 756b46ddd24 and later 47e88b33b
fbe740
which added a string that needed to be copied.
fbe740
fbe740
https://bugzilla.redhat.com/show_bug.cgi?id=1814923
fbe740
fbe740
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
fbe740
(cherry picked from commit 299796328c34a30295d6cdc7ebce5d65843e921f)
fbe740
Message-Id: <2e350bb771f75d9fd068f69a595401907d92ca33.1584696274.git.pkrempa@redhat.com>
fbe740
Reviewed-by: Ján Tomko <jtomko@redhat.com>
fbe740
---
fbe740
 src/util/virstorageencryption.c | 8 +++-----
fbe740
 1 file changed, 3 insertions(+), 5 deletions(-)
fbe740
fbe740
diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c
fbe740
index 74836d4a00..6765fdc23a 100644
fbe740
--- a/src/util/virstorageencryption.c
fbe740
+++ b/src/util/virstorageencryption.c
fbe740
@@ -85,12 +85,10 @@ virStorageEncryptionFree(virStorageEncryptionPtr enc)
fbe740
 static virStorageEncryptionSecretPtr
fbe740
 virStorageEncryptionSecretCopy(const virStorageEncryptionSecret *src)
fbe740
 {
fbe740
-    virStorageEncryptionSecretPtr ret;
fbe740
-
fbe740
-    if (VIR_ALLOC(ret) < 0)
fbe740
-        return NULL;
fbe740
+    virStorageEncryptionSecretPtr ret = g_new0(virStorageEncryptionSecret, 1);
fbe740
 
fbe740
-    memcpy(ret, src, sizeof(*src));
fbe740
+    ret->type = src->type;
fbe740
+    virSecretLookupDefCopy(&ret->seclookupdef, &src->seclookupdef);
fbe740
 
fbe740
     return ret;
fbe740
 }
fbe740
-- 
fbe740
2.25.1
fbe740