Skip to content

Commit a3cb5a1

Browse files
committed
Fix crash and storage corruption
When object creation fails, remove object completely, otherwise storage will be attempted and corruption / crashes happen.
1 parent 6e43521 commit a3cb5a1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/crypto.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,8 +1082,11 @@ CK_RV C_CreateObject(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
10821082
return rv;
10831083
}
10841084
rv = AddObject(session, object, pTemplate, ulCount, phObject);
1085-
if (rv != CKR_OK)
1085+
if (rv != CKR_OK) {
1086+
WP11_Session_RemoveObject(session, object);
10861087
WP11_Object_Free(object);
1088+
object = NULL;
1089+
}
10871090

10881091
WOLFPKCS11_LEAVE("C_CreateObject", rv);
10891092
return rv;

0 commit comments

Comments
 (0)