]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
decrypt_packet_tls13: add check for max plaintext size
authorDaiki Ueno <dueno@redhat.com>
Thu, 31 Jan 2019 15:56:55 +0000 (16:56 +0100)
committerDaiki Ueno <dueno@redhat.com>
Thu, 14 Feb 2019 12:23:09 +0000 (13:23 +0100)
There is check in _gnutls_recv_in_buffers already, but for TLS 1.3 we
need to take account of the padding.

Signed-off-by: Daiki Ueno <dueno@redhat.com>
lib/cipher.c

index 3ea1cb1bb24966fb032706d4e5162a72e8f2112e..28075b00d1241317354b9381db695230c9cc8a4d 100644 (file)
@@ -872,6 +872,15 @@ decrypt_packet_tls13(gnutls_session_t session,
        if (unlikely(ret < 0))
                return gnutls_assert_val(ret);
 
+       /* 1 octet for content type */
+       if (length > max_decrypted_size(session) + 1) {
+               _gnutls_audit_log
+                   (session, "Received packet with illegal length: %u\n",
+                    (unsigned int) length);
+
+               return gnutls_assert_val(GNUTLS_E_RECORD_OVERFLOW);
+       }
+
        length_set = 0;
 
        /* now figure the actual data size. We intentionally iterate through all data,