]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ssl: avoid integer overflow by casting sum terms to size_t and not the result
authorHerman Semenoff <GermanAizek@yandex.ru>
Sat, 25 Apr 2026 04:22:54 +0000 (07:22 +0300)
committerEugene Syromiatnikov <esyr@openssl.org>
Mon, 1 Jun 2026 07:21:24 +0000 (09:21 +0200)
Avoid possible integer overflow:  instead of casting the sum to size_t,
each operand of the sum is cast to size_t before addition to avoid int
overflow.

Signed-off-by: Herman Semenoff <GermanAizek@yandex.ru>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Mon Jun  1 07:24:21 2026
(Merged from https://github.com/openssl/openssl/pull/30972)

ssl/quic/quic_port.c
ssl/record/methods/tls13_meth.c

index 42b121103d788af9278846df2d0c8a82958f1fbd..e29e4bcf74be9c0aad3dc297a3373039493accf7 100644 (file)
@@ -1136,7 +1136,7 @@ static int decrypt_validation_token(const QUIC_PORT *port,
         goto err;
 
     /* Prevent decryption of a buffer that is not within reasonable bounds */
-    if (ct_len < (size_t)(iv_len + tag_len) || ct_len > ENCRYPTED_TOKEN_MAX_LEN)
+    if (ct_len < (size_t)iv_len + tag_len || ct_len > ENCRYPTED_TOKEN_MAX_LEN)
         goto err;
 
     *pt_len = ct_len - iv_len - tag_len;
index ade57396224daefc3632899856f60ebb661be26f..e091d8d38216b0e376a88507f7d7946687e038e9 100644 (file)
@@ -236,7 +236,7 @@ static int tls13_cipher(OSSL_RECORD_LAYER *rl, TLS_RL_RECORD *recs,
                (unsigned int)rec->length)
             <= 0
         || EVP_CipherFinal_ex(enc_ctx, rec->data + lenu, &lenf) <= 0
-        || (size_t)(lenu + lenf) != rec->length) {
+        || (size_t)lenu + lenf != rec->length) {
         return 0;
     }
     if (sending) {