[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/13] crypto: Fix memory leaks in set_loaded for tls-*
From: |
Daniel P . Berrangé |
Subject: |
[PULL 04/13] crypto: Fix memory leaks in set_loaded for tls-* |
Date: |
Fri, 29 Jan 2021 17:10:53 +0000 |
From: Kevin Wolf <kwolf@redhat.com>
If you set the loaded property to true when it was already true, the
state is overwritten without freeing the old state first. Change the
set_loaded callback so that it always frees the old state (which is a
no-op if nothing was loaded) and only then load if requestsd.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
crypto/tlscredsanon.c | 3 +--
crypto/tlscredspsk.c | 3 +--
crypto/tlscredsx509.c | 3 +--
3 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/crypto/tlscredsanon.c b/crypto/tlscredsanon.c
index 30275b6847..bea5f76c55 100644
--- a/crypto/tlscredsanon.c
+++ b/crypto/tlscredsanon.c
@@ -123,10 +123,9 @@ qcrypto_tls_creds_anon_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsAnon *creds = QCRYPTO_TLS_CREDS_ANON(obj);
+ qcrypto_tls_creds_anon_unload(creds);
if (value) {
qcrypto_tls_creds_anon_load(creds, errp);
- } else {
- qcrypto_tls_creds_anon_unload(creds);
}
}
diff --git a/crypto/tlscredspsk.c b/crypto/tlscredspsk.c
index e26807b899..f5a31108d1 100644
--- a/crypto/tlscredspsk.c
+++ b/crypto/tlscredspsk.c
@@ -192,10 +192,9 @@ qcrypto_tls_creds_psk_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsPSK *creds = QCRYPTO_TLS_CREDS_PSK(obj);
+ qcrypto_tls_creds_psk_unload(creds);
if (value) {
qcrypto_tls_creds_psk_load(creds, errp);
- } else {
- qcrypto_tls_creds_psk_unload(creds);
}
}
diff --git a/crypto/tlscredsx509.c b/crypto/tlscredsx509.c
index c89dd62435..dbadad4df2 100644
--- a/crypto/tlscredsx509.c
+++ b/crypto/tlscredsx509.c
@@ -694,10 +694,9 @@ qcrypto_tls_creds_x509_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsX509 *creds = QCRYPTO_TLS_CREDS_X509(obj);
+ qcrypto_tls_creds_x509_unload(creds);
if (value) {
qcrypto_tls_creds_x509_load(creds, errp);
- } else {
- qcrypto_tls_creds_x509_unload(creds);
}
}
--
2.29.2
- [PULL 00/13] Misc patches, Daniel P . Berrangé, 2021/01/29
- [PULL 01/13] crypto: Fix some code style problems, add spaces around operator, Daniel P . Berrangé, 2021/01/29
- [PULL 02/13] crypto: Move USER_CREATABLE to secret_common base class, Daniel P . Berrangé, 2021/01/29
- [PULL 03/13] crypto: Forbid broken unloading of secrets, Daniel P . Berrangé, 2021/01/29
- [PULL 05/13] os: deprecate the -enable-fips option and QEMU's FIPS enforcement, Daniel P . Berrangé, 2021/01/29
- [PULL 06/13] Prefer 'on' | 'off' over 'yes' | 'no' for bool options, Daniel P . Berrangé, 2021/01/29
- [PULL 04/13] crypto: Fix memory leaks in set_loaded for tls-*,
Daniel P . Berrangé <=
- [PULL 07/13] docs: simplify and clarify the platform support rules, Daniel P . Berrangé, 2021/01/29
- [PULL 08/13] docs: fix missing backslash in certtool shell example, Daniel P . Berrangé, 2021/01/29
- [PULL 09/13] configure: replace --enable/disable-git-update with --with-git-submodules, Daniel P . Berrangé, 2021/01/29
- [PULL 10/13] crypto: Add spaces around operator, Daniel P . Berrangé, 2021/01/29
- [PULL 11/13] ui: update keycodemapdb submodule commit, Daniel P . Berrangé, 2021/01/29
- [PULL 12/13] tests: Fix runtime error in test-authz-pam, Daniel P . Berrangé, 2021/01/29
- [PULL 13/13] tests: Replace deprecated ASN1 code, Daniel P . Berrangé, 2021/01/29
- Re: [PULL 00/13] Misc patches, no-reply, 2021/01/29
- Re: [PULL 00/13] Misc patches, Peter Maydell, 2021/01/29