diff options
author | Gilles Peskine <gilles.peskine@arm.com> | 2024-04-30 09:48:20 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-30 09:48:20 +0000 |
commit | 489688c0f7eddf57334d1d7e8ad0f03ba6bf82d0 (patch) | |
tree | e132dafe5ab540a1a10da4a4054d45b5b2a4db35 | |
parent | 024d3daa7d367e58aaab6a5b06e42aa440e3fa37 (diff) | |
parent | 0f37a157a272a8b60fe045ec1301ebb0995c3d06 (diff) | |
download | mbedtls-upstream-development.tar.gz |
Merge pull request #9065 from paul-elliott-arm/fix_ubsan_mp_aead_gcmupstream-development
Add early exit if zero length AEAD additional data passed in.
-rw-r--r-- | ChangeLog.d/fix_ubsan_mp_aead_gcm.txt | 3 | ||||
-rw-r--r-- | library/psa_crypto.c | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/ChangeLog.d/fix_ubsan_mp_aead_gcm.txt b/ChangeLog.d/fix_ubsan_mp_aead_gcm.txt new file mode 100644 index 000000000..e4726a45d --- /dev/null +++ b/ChangeLog.d/fix_ubsan_mp_aead_gcm.txt @@ -0,0 +1,3 @@ +Bugfix + * Fix undefined behaviour (incrementing a NULL pointer by zero length) when + passing in zero length additional data to multipart AEAD. diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 969c695ac..0a9011ad8 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -5194,6 +5194,12 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation, goto exit; } + /* No input to add (zero length), nothing to do. */ + if (input_length == 0) { + status = PSA_SUCCESS; + goto exit; + } + if (operation->lengths_set) { if (operation->ad_remaining < input_length) { status = PSA_ERROR_INVALID_ARGUMENT; |