libvirt/SOURCES/libvirt-virStorageEncryptionSecretCopy-Properly-copy-internals.patch
2021-09-10 11:57:33 +00:00

51 lines
1.8 KiB
Diff

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