From 68bc026d96ee568bf47745ee59035c8f9200179e Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 13 Nov 2009 04:27:40 +0000 Subject: Fix semantics when attribute retrieved with too small buffer. --- src/object.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/object.c b/src/object.c index 9b36b93..cb4b59c 100644 --- a/src/object.c +++ b/src/object.c @@ -5,7 +5,7 @@ #include /* An very likey to be invalid attribute */ -#define CKA_INVALID (CKA_VENDOR_DEFINED | 0x00FFFFFF) +#define CKA_INVALID 0x80FFFFFFUL /* ---------------------------------------------------------------------------------- * TESTS @@ -212,7 +212,7 @@ test_get_attribute_value(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object) attrs[0].ulValueLen = 2; rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, attrs, 1); P11T_CHECK_RV("Buffer too small", rv, CKR_BUFFER_TOO_SMALL); - P11T_CHECK_ULONG("Buffer too small should return size", attrs[0].ulValueLen, sizeof(CK_OBJECT_CLASS)); + P11T_CHECK_ULONG("Buffer too small should return -1", attrs[0].ulValueLen, (CK_ULONG)-1); } attrs[0].pValue = NULL; @@ -305,7 +305,7 @@ test_get_attribute_value(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object) rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, attrs, 5); P11T_CHECK_RV("Multiple attributes, one small buffer", rv, CKR_BUFFER_TOO_SMALL); - P11T_CHECK_ULONG("Size of CKA_CLASS", attrs[0].ulValueLen, sizeof(CK_OBJECT_CLASS)); + P11T_CHECK_ULONG("Invalid attribute size", attrs[0].ulValueLen, (CK_ULONG)-1); P11T_CHECK_BOOL("CKA_TOKEN boolean value", *((CK_BBOOL*)attrs[1].pValue)); P11T_CHECK_BOOL("CKA_PRIVATE boolean value", *((CK_BBOOL*)attrs[2].pValue)); P11T_CHECK_BOOL("CKA_MODIFIABLE boolean value", *((CK_BBOOL*)attrs[3].pValue)); -- cgit v1.2.3