diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/lib/pkcs11/pkcs11_kernel/common/kernelUtil.c | 3 | ||||
-rw-r--r-- | usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c | 21 |
2 files changed, 16 insertions, 8 deletions
diff --git a/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelUtil.c b/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelUtil.c index 7efe0a9208..4abc5e97f5 100644 --- a/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelUtil.c +++ b/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelUtil.c @@ -23,7 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <stdlib.h> #include <string.h> @@ -808,7 +807,7 @@ process_object_attributes(CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount, value_len = sizeof (ulong_t); if (pTemplate[i].pValue != NULL && (pTemplate[i].ulValueLen < value_len)) { - rv = CKR_BUFFER_TOO_SMALL; + rv = CKR_ATTRIBUTE_VALUE_INVALID; cur_i = i; goto fail_cleanup; } diff --git a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c index dec3ddd6e0..c139863b23 100644 --- a/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c +++ b/usr/src/lib/pkcs11/pkcs11_softtoken/common/softAttributeUtil.c @@ -23,8 +23,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdlib.h> #include <string.h> #include <security/cryptoki.h> @@ -852,15 +850,20 @@ get_ulong_attr_from_object(CK_ULONG value, CK_ATTRIBUTE_PTR template) * Copy the CK_ULONG data type attribute value from a template to the * object. */ -void +static CK_RV get_ulong_attr_from_template(CK_ULONG *value, CK_ATTRIBUTE_PTR template) { + if (template->ulValueLen < sizeof (CK_ULONG)) + return (CKR_ATTRIBUTE_VALUE_INVALID); + if (template->pValue != NULL) { *value = *(CK_ULONG_PTR)template->pValue; } else { *value = 0; } + + return (CKR_OK); } /* @@ -1484,8 +1487,10 @@ soft_build_public_key_object(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum, case CKA_MODULUS_BITS: isModulusBits = 1; - get_ulong_attr_from_template(&modulus_bits, + rv = get_ulong_attr_from_template(&modulus_bits, &template[i]); + if (rv != CKR_OK) + goto fail_cleanup; break; case CKA_LABEL: @@ -2086,8 +2091,10 @@ soft_build_private_key_object(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum, case CKA_VALUE_BITS: isValueBits = 1; - get_ulong_attr_from_template(&value_bits, + rv = get_ulong_attr_from_template(&value_bits, &template[i]); + if (rv != CKR_OK) + goto fail_cleanup; break; case CKA_LABEL: @@ -2613,8 +2620,10 @@ soft_build_secret_key_object(CK_ATTRIBUTE_PTR template, CK_ULONG ulAttrNum, case CKA_VALUE_LEN: isValueLen = 1; - get_ulong_attr_from_template(&sck->sk_value_len, + rv = get_ulong_attr_from_template(&sck->sk_value_len, &template[i]); + if (rv != CKR_OK) + goto fail_cleanup; break; case CKA_LABEL: |