ncrypt_pkcs11: fix buffer allocation for key name

This commit is contained in:
David Fort 2022-11-29 22:53:13 +01:00 committed by David Fort
parent 0091f72761
commit bc8afa0ad5
1 changed files with 4 additions and 4 deletions

View File

@ -920,13 +920,13 @@ static SECURITY_STATUS check_for_piv_container_name(NCryptP11KeyHandle* key, BYT
{
if (strncmp(label, piv_cert_tags[i].label, label_len) == 0)
{
*pcbResult = PIV_CONTAINER_NAME_LEN * sizeof(WCHAR);
*pcbResult = (PIV_CONTAINER_NAME_LEN + 1) * sizeof(WCHAR);
if (!pbOutput)
return ERROR_SUCCESS;
else if (cbOutput < PIV_CONTAINER_NAME_LEN * sizeof(WCHAR))
if (cbOutput < (PIV_CONTAINER_NAME_LEN + 1) * sizeof(WCHAR))
return NTE_NO_MEMORY;
else
return get_piv_container_name(key, piv_cert_tags[i].tag, pbOutput, cbOutput);
return get_piv_container_name(key, piv_cert_tags[i].tag, pbOutput, cbOutput);
}
}
return NTE_NOT_FOUND;