Skip to content

Commit

Permalink
Merge pull request #1010 from AndrzejKurek/fix-error-translation
Browse files Browse the repository at this point in the history
psa_util: fix for correctly computing elements in array
  • Loading branch information
paul-elliott-arm authored Mar 27, 2023
2 parents a33da45 + ab9dc66 commit 1873d3b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
6 changes: 4 additions & 2 deletions include/mbedtls/psa_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,10 @@ int psa_status_to_mbedtls(psa_status_t status,
int psa_pk_status_to_mbedtls(psa_status_t status);

/* Utility macro to shorten the defines of error translator in modules. */
#define PSA_TO_MBEDTLS_ERR_LIST(status, error_list, fallback_f) \
psa_status_to_mbedtls(status, error_list, sizeof(error_list), fallback_f)
#define PSA_TO_MBEDTLS_ERR_LIST(status, error_list, fallback_f) \
psa_status_to_mbedtls(status, error_list, \
sizeof(error_list)/sizeof(error_list[0]), \
fallback_f)

#endif /* MBEDTLS_PSA_CRYPTO_C */
#endif /* MBEDTLS_PSA_UTIL_H */
3 changes: 1 addition & 2 deletions library/psa_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,9 @@ int psa_generic_status_to_mbedtls(psa_status_t status)

int psa_status_to_mbedtls(psa_status_t status,
const mbedtls_error_pair_t *local_translations,
size_t local_errors_size,
size_t local_errors_num,
int (*fallback_f)(psa_status_t))
{
size_t local_errors_num = (size_t) local_errors_size / 2;
for (size_t i = 0; i < local_errors_num; i++) {
if (status == local_translations[i].psa_status) {
return local_translations[i].mbedtls_error;
Expand Down

0 comments on commit 1873d3b

Please sign in to comment.