summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-06-29 18:52:22 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-06-29 19:06:41 +0200
commitb3bdd7df6193a8151d1196151a5041737c25c5ff (patch)
treeaf147a47a20e9e129a8e08e0864630756bb0ae7c
parent1630ba265dc6e2a40077e4610b6783b228b79aa6 (diff)
downloadgnutls-b3bdd7df6193a8151d1196151a5041737c25c5ff.tar.gz
pkcs11_get_attribute_avalue: do not assign values on failure
When C_GetAttributeValue() returns size but does not return data then pkcs11_get_attribute_avalue() would set the return data pointer to a free'd value. This is against the convention expected by callers, i.e, set data to NULL. Reported by Anthony Alba in #108.
-rw-r--r--lib/pkcs11_int.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/pkcs11_int.c b/lib/pkcs11_int.c
index 9ff2d98bcf..de3d4e5cdc 100644
--- a/lib/pkcs11_int.c
+++ b/lib/pkcs11_int.c
@@ -138,6 +138,7 @@ pkcs11_get_attribute_avalue(struct ck_function_list * module,
rv = (module)->C_GetAttributeValue(sess, object, &templ, 1);
if (rv != CKR_OK) {
gnutls_free(t);
+ return rv;
}
res->data = t;
res->size = templ.value_len;