[PATCH 2/2] virStorageEncryptionSecretCopy: Properly copy internals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



virStorageEncryptionSecretPtr may have a string inside it, thus we must
copy the string too. Use virSecretLookupDefCopy to do that.

Likely caused by 756b46ddd24.

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

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 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.24.1





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux