Skip to content

Commit

Permalink
libckteec: Fix CK_ULONG conversions in C_GetTokenInfo()
Browse files Browse the repository at this point in the history
When running in 64 bit CPU things like ulMaxSessionCount would get value
of 4294967295 instead of ~0.

Adjust all other CK_ULONG fields while at it.

Signed-off-by: Vesa Jääskeläinen <[email protected]>
  • Loading branch information
vesajaaskelainen committed Dec 6, 2023
1 parent 4f926de commit 9b76a10
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions libckteec/src/pkcs11_token.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,16 @@ CK_RV ck_token_get_info(CK_SLOT_ID slot, CK_TOKEN_INFO_PTR info)
sizeof(info->serialNumber));

info->flags = ta_info->flags;
info->ulMaxSessionCount = ta_info->max_session_count;
info->ulSessionCount = ta_info->session_count;
info->ulMaxRwSessionCount = ta_info->max_rw_session_count;
info->ulRwSessionCount = ta_info->rw_session_count;
info->ulMaxPinLen = ta_info->max_pin_len;
info->ulMinPinLen = ta_info->min_pin_len;
info->ulTotalPublicMemory = ta_info->total_public_memory;
info->ulFreePublicMemory = ta_info->free_public_memory;
info->ulTotalPrivateMemory = ta_info->total_private_memory;
info->ulFreePrivateMemory = ta_info->free_private_memory;
info->ulMaxSessionCount = TO_CK_ULONG(ta_info->max_session_count);
info->ulSessionCount = TO_CK_ULONG(ta_info->session_count);
info->ulMaxRwSessionCount = TO_CK_ULONG(ta_info->max_rw_session_count);
info->ulRwSessionCount = TO_CK_ULONG(ta_info->rw_session_count);
info->ulMaxPinLen = TO_CK_ULONG(ta_info->max_pin_len);
info->ulMinPinLen = TO_CK_ULONG(ta_info->min_pin_len);
info->ulTotalPublicMemory = TO_CK_ULONG(ta_info->total_public_memory);
info->ulFreePublicMemory = TO_CK_ULONG(ta_info->free_public_memory);
info->ulTotalPrivateMemory = TO_CK_ULONG(ta_info->total_private_memory);
info->ulFreePrivateMemory = TO_CK_ULONG(ta_info->free_private_memory);

COMPILE_TIME_ASSERT(sizeof(info->hardwareVersion) ==
sizeof(ta_info->hardware_version));
Expand Down

0 comments on commit 9b76a10

Please sign in to comment.