diff mbox series

crypto: fix getter of a QCryptoSecret's property

Message ID 1578600598-335744-1-git-send-email-tong.ho@xilinx.com
State New
Headers show
Series crypto: fix getter of a QCryptoSecret's property | expand

Commit Message

Tong Ho Jan. 9, 2020, 8:09 p.m. UTC
This fixes the condition-check done by the "loaded" property
getter, such that the property returns true even when the
secret is loaded by the 'file' option.

Signed-off-by: Tong Ho <tong.ho@xilinx.com>
---
 Pre-existing getter returns true only when the secret is loaded
 by the 'data' option.

 crypto/secret.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Daniel P. Berrangé Jan. 10, 2020, 9:35 a.m. UTC | #1
On Thu, Jan 09, 2020 at 12:09:58PM -0800, Tong Ho wrote:
> This fixes the condition-check done by the "loaded" property
> getter, such that the property returns true even when the
> secret is loaded by the 'file' option.
> 
> Signed-off-by: Tong Ho <tong.ho@xilinx.com>
> ---
>  Pre-existing getter returns true only when the secret is loaded
>  by the 'data' option.
> 
>  crypto/secret.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>

Added to my pending queue


Regards,
Daniel
diff mbox series

Patch

diff --git a/crypto/secret.c b/crypto/secret.c
index 1cf0ad0..5fb6bbe 100644
--- a/crypto/secret.c
+++ b/crypto/secret.c
@@ -221,6 +221,7 @@  qcrypto_secret_prop_set_loaded(Object *obj,
         secret->rawlen = inputlen;
     } else {
         g_free(secret->rawdata);
+        secret->rawdata = NULL;
         secret->rawlen = 0;
     }
 }
@@ -231,7 +232,7 @@  qcrypto_secret_prop_get_loaded(Object *obj,
                                Error **errp G_GNUC_UNUSED)
 {
     QCryptoSecret *secret = QCRYPTO_SECRET(obj);
-    return secret->data != NULL;
+    return secret->rawdata != NULL;
 }