[pkg-opensc-commit] [opensc] 29/295: pkcs11-tool: no error when getting sensitive attr. value
Eric Dorland
eric at moszumanska.debian.org
Sat Jun 24 21:11:13 UTC 2017
This is an automated email from the git hooks/post-receive script.
eric pushed a commit to branch master
in repository opensc.
commit 76e0e1946000c2f193e5880911829e00d423788e
Author: Viktor Tarasov <viktor.tarasov at gmail.com>
Date: Thu Jun 23 18:51:12 2016 +0200
pkcs11-tool: no error when getting sensitive attr. value
resolves PR #807
---
src/tools/pkcs11-tool.c | 35 +++++++++++++++++++++--------------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/src/tools/pkcs11-tool.c b/src/tools/pkcs11-tool.c
index 6995c25..1c32b74 100644
--- a/src/tools/pkcs11-tool.c
+++ b/src/tools/pkcs11-tool.c
@@ -2645,20 +2645,27 @@ get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj) \
static TYPE * \
get##ATTR(CK_SESSION_HANDLE sess, CK_OBJECT_HANDLE obj, CK_ULONG_PTR pulCount) \
{ \
- CK_ATTRIBUTE attr = { CKA_##ATTR, NULL, 0 }; \
- CK_RV rv; \
- \
- rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
- if (rv == CKR_OK) { \
- if (!(attr.pValue = calloc(1, attr.ulValueLen + 1))) \
- util_fatal("out of memory in get" #ATTR ": %m"); \
- rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
- if (pulCount) \
- *pulCount = attr.ulValueLen / sizeof(TYPE); \
- } else {\
- p11_warn("C_GetAttributeValue(" #ATTR ")", rv); \
- } \
- return (TYPE *) attr.pValue; \
+ CK_ATTRIBUTE attr = { CKA_##ATTR, NULL, 0 }; \
+ CK_RV rv; \
+ if (pulCount) \
+ *pulCount = 0; \
+ rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
+ if (rv == CKR_OK) { \
+ if (attr.ulValueLen == (CK_ULONG)(-1)) \
+ return NULL; \
+ if (!(attr.pValue = calloc(1, attr.ulValueLen + 1))) \
+ util_fatal("out of memory in get" #ATTR ": %m"); \
+ rv = p11->C_GetAttributeValue(sess, obj, &attr, 1); \
+ if (attr.ulValueLen == (CK_ULONG)(-1)) { \
+ free(attr.pValue); \
+ return NULL; \
+ } \
+ if (pulCount) \
+ *pulCount = attr.ulValueLen / sizeof(TYPE); \
+ } else { \
+ p11_warn("C_GetAttributeValue(" #ATTR ")", rv); \
+ } \
+ return (TYPE *) attr.pValue; \
}
/*
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/opensc.git
More information about the pkg-opensc-commit
mailing list