Skip to content

Commit 281c0a2

Browse files
committed
Fix things found in review
* `getVarLen` should be re-initialized before the second `WP11_Object_GetAttr` call. * Session leaks if `C_Login` fails.
1 parent 7e4946e commit 281c0a2

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

src/crypto.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,7 @@ static CK_RV SetAttributeValue(WP11_Session* session, WP11_Object* obj,
706706
}
707707
/* Cannot change extractable from false to true */
708708
if (!newObject && attr->type == CKA_EXTRACTABLE) {
709+
getVarLen = sizeof(getVar);
709710
rv = WP11_Object_GetAttr(obj, CKA_EXTRACTABLE, &getVar,
710711
&getVarLen);
711712
if (rv != CKR_OK)

tests/find_objects_null_template_test.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,10 @@ static CK_RV pkcs11_open_session(CK_SESSION_HANDLE* session)
197197
return ret;
198198

199199
ret = funcList->C_Login(*session, CKU_USER, userPin, userPinLen);
200-
if (ret != CKR_OK)
200+
if (ret != CKR_OK) {
201+
funcList->C_CloseSession(*session);
201202
return ret;
203+
}
202204

203205
return CKR_OK;
204206
}

0 commit comments

Comments
 (0)