Merge pull request #8615 from davidhorstmann-arm/fix-cast-potential-overflow

Fix possible integer overflows
This commit is contained in:
Gilles Peskine 2023-12-07 00:42:10 +00:00 committed by GitHub
commit f3ccfddb45
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -753,7 +753,8 @@ static int ssl_prepare_client_hello(mbedtls_ssl_context *ssl)
session_negotiate->ticket != NULL) {
mbedtls_ms_time_t now = mbedtls_ms_time();
mbedtls_ms_time_t age = now - session_negotiate->ticket_reception_time;
if (age < 0 || age > session_negotiate->ticket_lifetime * 1000) {
if (age < 0 ||
age > (mbedtls_ms_time_t) session_negotiate->ticket_lifetime * 1000) {
/* Without valid ticket, disable session resumption.*/
MBEDTLS_SSL_DEBUG_MSG(
3, ("Ticket expired, disable session resumption"));

View file

@ -510,7 +510,8 @@ int mbedtls_ssl_ticket_parse(void *p_ticket,
}
#endif
mbedtls_ms_time_t ticket_lifetime = ctx->ticket_lifetime * 1000;
mbedtls_ms_time_t ticket_lifetime =
(mbedtls_ms_time_t) ctx->ticket_lifetime * 1000;
if (ticket_age < 0 || ticket_age > ticket_lifetime) {
ret = MBEDTLS_ERR_SSL_SESSION_TICKET_EXPIRED;