mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-07-26 11:50:40 +08:00
Guard memcpy so that it won't fail on null input pointer
Signed-off-by: Ryan Everett <ryan.everett@arm.com>
This commit is contained in:
parent
b41c3c9582
commit
5d2e82f0ce
@ -6864,12 +6864,12 @@ static psa_status_t psa_pbkdf2_hmac_set_password(psa_algorithm_t hash_alg,
|
|||||||
{
|
{
|
||||||
psa_status_t status = PSA_SUCCESS;
|
psa_status_t status = PSA_SUCCESS;
|
||||||
if (input_len > PSA_HASH_BLOCK_LENGTH(hash_alg)) {
|
if (input_len > PSA_HASH_BLOCK_LENGTH(hash_alg)) {
|
||||||
status = psa_hash_compute(hash_alg, input, input_len, output,
|
return psa_hash_compute(hash_alg, input, input_len, output,
|
||||||
PSA_HMAC_MAX_HASH_BLOCK_SIZE, output_len);
|
PSA_HMAC_MAX_HASH_BLOCK_SIZE, output_len);
|
||||||
} else {
|
} else if (input_len > 0) {
|
||||||
memcpy(output, input, input_len);
|
memcpy(output, input, input_len);
|
||||||
*output_len = PSA_HASH_BLOCK_LENGTH(hash_alg);
|
|
||||||
}
|
}
|
||||||
|
*output_len = PSA_HASH_BLOCK_LENGTH(hash_alg);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC */
|
#endif /* MBEDTLS_PSA_BUILTIN_ALG_PBKDF2_HMAC */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user