mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-03-23 16:20:49 +00:00
Handle sizeof(size_t) > sizeof(uint64_t)
Signed-off-by: Chien Wong <m@xv97.com>
This commit is contained in:
parent
858bc65d74
commit
019c2a7817
@ -358,7 +358,12 @@ int mbedtls_gcm_update_ad(mbedtls_gcm_context *ctx,
|
||||
|
||||
/* AD is limited to 2^64 bits, ie 2^61 bytes
|
||||
* Also check for possible overflow */
|
||||
new_add_len = ctx->add_len + add_len;
|
||||
#if SIZE_MAX > 0xFFFFFFFFFFFFFFFFULL
|
||||
if (add_len > 0xFFFFFFFFFFFFFFFFULL) {
|
||||
return MBEDTLS_ERR_GCM_BAD_INPUT;
|
||||
}
|
||||
#endif
|
||||
new_add_len = ctx->add_len + (uint64_t) add_len;
|
||||
if (new_add_len < ctx->add_len || new_add_len >> 61 != 0) {
|
||||
return MBEDTLS_ERR_GCM_BAD_INPUT;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user