|
|
d76c62 |
From 044e5a7db716235c167f76974d4bd7566248cf9a Mon Sep 17 00:00:00 2001
|
|
|
d76c62 |
Message-Id: <044e5a7db716235c167f76974d4bd7566248cf9a@dist-git>
|
|
|
d76c62 |
From: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Date: Mon, 16 Mar 2020 22:11:45 +0100
|
|
|
d76c62 |
Subject: [PATCH] qemuDomainSecretAESSetup: Automatically free non-secret
|
|
|
d76c62 |
locals
|
|
|
d76c62 |
MIME-Version: 1.0
|
|
|
d76c62 |
Content-Type: text/plain; charset=UTF-8
|
|
|
d76c62 |
Content-Transfer-Encoding: 8bit
|
|
|
d76c62 |
|
|
|
d76c62 |
Use g_autofree for the ciphertext and init vector as they are not
|
|
|
d76c62 |
secret and thus don't have to be cleared and use g_new0 to allocate the
|
|
|
d76c62 |
iv for parity.
|
|
|
d76c62 |
|
|
|
d76c62 |
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
(cherry picked from commit 88126d5f0ec3899dbc3bc223d120de159ded9dca)
|
|
|
d76c62 |
|
|
|
d76c62 |
Conflicts:
|
|
|
d76c62 |
src/qemu/qemu_domain.c:
|
|
|
d76c62 |
20fa2bc6e52e01feaf39d12d38bcf8eaec4c9a46 was not backported
|
|
|
d76c62 |
and thus this patch also effectively backports the modification
|
|
|
d76c62 |
the patch mentioned above did to qemuDomainSecretAESSetup as it
|
|
|
d76c62 |
would not result in a clean backport.
|
|
|
d76c62 |
|
|
|
d76c62 |
https://bugzilla.redhat.com/show_bug.cgi?id=1804750
|
|
|
d76c62 |
Message-Id: <6d4512020332b977f8de5843469e0d030f4f65d3.1584391726.git.pkrempa@redhat.com>
|
|
|
d76c62 |
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
|
|
d76c62 |
---
|
|
|
d76c62 |
src/qemu/qemu_domain.c | 17 ++++++-----------
|
|
|
d76c62 |
1 file changed, 6 insertions(+), 11 deletions(-)
|
|
|
d76c62 |
|
|
|
d76c62 |
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
|
|
|
d76c62 |
index b77488026a..b26187659e 100644
|
|
|
d76c62 |
--- a/src/qemu/qemu_domain.c
|
|
|
d76c62 |
+++ b/src/qemu/qemu_domain.c
|
|
|
d76c62 |
@@ -1542,16 +1542,15 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv,
|
|
|
d76c62 |
virSecretLookupTypeDefPtr seclookupdef,
|
|
|
d76c62 |
bool isLuks)
|
|
|
d76c62 |
{
|
|
|
d76c62 |
- virConnectPtr conn;
|
|
|
d76c62 |
+ g_autoptr(virConnect) conn = virGetConnectSecret();
|
|
|
d76c62 |
int ret = -1;
|
|
|
d76c62 |
- uint8_t *raw_iv = NULL;
|
|
|
d76c62 |
+ g_autofree uint8_t *raw_iv = NULL;
|
|
|
d76c62 |
size_t ivlen = QEMU_DOMAIN_AES_IV_LEN;
|
|
|
d76c62 |
uint8_t *secret = NULL;
|
|
|
d76c62 |
size_t secretlen = 0;
|
|
|
d76c62 |
- uint8_t *ciphertext = NULL;
|
|
|
d76c62 |
+ g_autofree uint8_t *ciphertext = NULL;
|
|
|
d76c62 |
size_t ciphertextlen = 0;
|
|
|
d76c62 |
|
|
|
d76c62 |
- conn = virGetConnectSecret();
|
|
|
d76c62 |
if (!conn)
|
|
|
d76c62 |
return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
@@ -1559,14 +1558,13 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv,
|
|
|
d76c62 |
secinfo->s.aes.username = g_strdup(username);
|
|
|
d76c62 |
|
|
|
d76c62 |
if (!(secinfo->s.aes.alias = qemuDomainGetSecretAESAlias(srcalias, isLuks)))
|
|
|
d76c62 |
- goto cleanup;
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
- if (VIR_ALLOC_N(raw_iv, ivlen) < 0)
|
|
|
d76c62 |
- goto cleanup;
|
|
|
d76c62 |
+ raw_iv = g_new0(uint8_t, ivlen);
|
|
|
d76c62 |
|
|
|
d76c62 |
/* Create a random initialization vector */
|
|
|
d76c62 |
if (virRandomBytes(raw_iv, ivlen) < 0)
|
|
|
d76c62 |
- goto cleanup;
|
|
|
d76c62 |
+ return -1;
|
|
|
d76c62 |
|
|
|
d76c62 |
/* Encode the IV and save that since qemu will need it */
|
|
|
d76c62 |
secinfo->s.aes.iv = g_base64_encode(raw_iv, ivlen);
|
|
|
d76c62 |
@@ -1592,10 +1590,7 @@ qemuDomainSecretAESSetup(qemuDomainObjPrivatePtr priv,
|
|
|
d76c62 |
ret = 0;
|
|
|
d76c62 |
|
|
|
d76c62 |
cleanup:
|
|
|
d76c62 |
- VIR_DISPOSE_N(raw_iv, ivlen);
|
|
|
d76c62 |
VIR_DISPOSE_N(secret, secretlen);
|
|
|
d76c62 |
- VIR_DISPOSE_N(ciphertext, ciphertextlen);
|
|
|
d76c62 |
- virObjectUnref(conn);
|
|
|
d76c62 |
return ret;
|
|
|
d76c62 |
}
|
|
|
d76c62 |
|
|
|
d76c62 |
--
|
|
|
d76c62 |
2.25.1
|
|
|
d76c62 |
|