Skip to content

Commit 489688c

Browse files
Merge pull request Mbed-TLS#9065 from paul-elliott-arm/fix_ubsan_mp_aead_gcm
Add early exit if zero length AEAD additional data passed in.
2 parents 024d3da + 0f37a15 commit 489688c

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ChangeLog.d/fix_ubsan_mp_aead_gcm.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Bugfix
2+
* Fix undefined behaviour (incrementing a NULL pointer by zero length) when
3+
passing in zero length additional data to multipart AEAD.

library/psa_crypto.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5194,6 +5194,12 @@ psa_status_t psa_aead_update_ad(psa_aead_operation_t *operation,
51945194
goto exit;
51955195
}
51965196

5197+
/* No input to add (zero length), nothing to do. */
5198+
if (input_length == 0) {
5199+
status = PSA_SUCCESS;
5200+
goto exit;
5201+
}
5202+
51975203
if (operation->lengths_set) {
51985204
if (operation->ad_remaining < input_length) {
51995205
status = PSA_ERROR_INVALID_ARGUMENT;

0 commit comments

Comments
 (0)