diff options
author | Daiki Ueno <dueno@redhat.com> | 2019-01-17 11:53:35 +0100 |
---|---|---|
committer | Daiki Ueno <dueno@redhat.com> | 2019-02-14 13:23:09 +0100 |
commit | 914f6fc1ae4953db7a02e7290db67a33f1b48689 (patch) | |
tree | 5cb43b78d4de312d68c7b00784602461391bafe6 /lib/gnutls_int.h | |
parent | ab953f5913b78479a83d72c660c23ab3d7a2c1b9 (diff) | |
download | gnutls-914f6fc1ae4953db7a02e7290db67a33f1b48689.tar.gz |
ext/record_size_limit: don't confuse with negotiated/user-supplied maximum
As documented in gnutls_int.h, max_record_send_size is for tracking
the user-supplied maximum, while max_record_recv_size for the
protocol negotiated maximum.
Signed-off-by: Daiki Ueno <dueno@redhat.com>
Diffstat (limited to 'lib/gnutls_int.h')
-rw-r--r-- | lib/gnutls_int.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/gnutls_int.h b/lib/gnutls_int.h index f99e40a171..2352299cd8 100644 --- a/lib/gnutls_int.h +++ b/lib/gnutls_int.h @@ -1358,6 +1358,7 @@ typedef struct { */ #define HSK_RECORD_SIZE_LIMIT_NEGOTIATED (1<<24) #define HSK_RECORD_SIZE_LIMIT_SENT (1<<25) /* record_size_limit extension was sent */ +#define HSK_RECORD_SIZE_LIMIT_RECEIVED (1<<26) /* server: record_size_limit extension was seen but not accepted yet */ /* The hsk_flags are for use within the ongoing handshake; * they are reset to zero prior to handshake start by gnutls_handshake. */ @@ -1547,17 +1548,20 @@ inline static int _gnutls_set_current_version(gnutls_session_t s, unsigned v) return 0; } +/* Returns the maximum size of the plaintext to be sent, considering + * both user-specified/negotiated maximum values. + */ inline static size_t max_user_send_size(gnutls_session_t session, record_parameters_st * record_params) { size_t max; - if (IS_DTLS(session)) { - max = MIN(gnutls_dtls_get_data_mtu(session), session->security_parameters.max_record_send_size); - } else { - max = session->security_parameters.max_record_send_size; - } + max = MIN(session->security_parameters.max_record_send_size, + session->security_parameters.max_record_recv_size); + + if (IS_DTLS(session)) + max = MIN(gnutls_dtls_get_data_mtu(session), max); return max; } |