Skip to contentSkip to conversation

crypto: fix getter of a QCryptoSecret's property

PATCH In review Tong Ho 2 participants 2 messages Jan 9, 2020 – Jan 10, 2020 Crypto API

lore
Share & tools
lore

Tong Ho

author
#0 lore raw

PATCH 1/1 crypto: fix getter of a QCryptoSecret's property

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.

---
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(-)
crypto/secret.c +2 -1
index 1cf0ad0..5fb6bbe 100644
@@ -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;
 }
 
 
Signature · 1 line
2.7.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Tong Ho

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.

---
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(-)

Added to my pending queue

Regards,
Daniel

Signature · 3 lines
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|