diff options
author | Daiki Ueno <dueno@redhat.com> | 2018-08-14 16:46:12 +0200 |
---|---|---|
committer | Daiki Ueno <dueno@redhat.com> | 2018-08-20 11:54:41 +0200 |
commit | 50f64a45933e10a71f8155dc57ab6f239ab46204 (patch) | |
tree | 417bd447aee272bef086e2ced82d445ab80223ea /lib/ext | |
parent | e30d157cb722efe9d8047369f627b20467ff62a5 (diff) | |
download | gnutls-50f64a45933e10a71f8155dc57ab6f239ab46204.tar.gz |
ext/max_record: remove use of extension private data
As the extension data is always stored in
session->security_parameters.max_record_send_size, it shouldn't be
necessary to track it with the private data.
Signed-off-by: Daiki Ueno <dueno@redhat.com>
Diffstat (limited to 'lib/ext')
-rw-r--r-- | lib/ext/max_record.c | 78 |
1 files changed, 11 insertions, 67 deletions
diff --git a/lib/ext/max_record.c b/lib/ext/max_record.c index 8314d16193..8edf5a2183 100644 --- a/lib/ext/max_record.c +++ b/lib/ext/max_record.c @@ -35,11 +35,6 @@ static int _gnutls_max_record_recv_params(gnutls_session_t session, static int _gnutls_max_record_send_params(gnutls_session_t session, gnutls_buffer_st * extdata); -static int _gnutls_max_record_unpack(gnutls_buffer_st * ps, - gnutls_ext_priv_data_t * _priv); -static int _gnutls_max_record_pack(gnutls_ext_priv_data_t _priv, - gnutls_buffer_st * ps); - /* Maps record size to numbers according to the * extensions draft. */ @@ -55,11 +50,7 @@ const hello_ext_entry_st ext_mod_max_record_size = { .validity = GNUTLS_EXT_FLAG_TLS | GNUTLS_EXT_FLAG_DTLS | GNUTLS_EXT_FLAG_CLIENT_HELLO | GNUTLS_EXT_FLAG_EE | GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO, .recv_func = _gnutls_max_record_recv_params, - .send_func = _gnutls_max_record_send_params, - .pack_func = _gnutls_max_record_pack, - .unpack_func = _gnutls_max_record_unpack, - .deinit_func = NULL, - .cannot_be_overriden = 0 + .send_func = _gnutls_max_record_send_params }; /* @@ -78,8 +69,6 @@ _gnutls_max_record_recv_params(gnutls_session_t session, { ssize_t new_size; ssize_t data_size = _data_size; - gnutls_ext_priv_data_t epriv; - int ret; if (session->security_parameters.entity == GNUTLS_SERVER) { if (data_size > 0) { @@ -100,14 +89,6 @@ _gnutls_max_record_recv_params(gnutls_session_t session, } else { /* CLIENT SIDE - we must check if the sent record size is the right one */ if (data_size > 0) { - ret = _gnutls_hello_ext_get_priv(session, - GNUTLS_EXTENSION_MAX_RECORD_SIZE, - &epriv); - if (ret < 0) { - gnutls_assert(); - return GNUTLS_E_INTERNAL_ERROR; - } - if (data_size != 1) { gnutls_assert(); return GNUTLS_E_UNEXPECTED_PACKET_LENGTH; @@ -115,13 +96,14 @@ _gnutls_max_record_recv_params(gnutls_session_t session, new_size = _gnutls_mre_num2record(data[0]); - if (new_size < 0 - || new_size != (intptr_t) epriv) { + if (new_size < 0 || + new_size != session->security_parameters. + max_record_send_size) { gnutls_assert(); return GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER; } else { session->security_parameters. - max_record_recv_size = (intptr_t)epriv; + max_record_recv_size = new_size; } } @@ -143,17 +125,13 @@ _gnutls_max_record_send_params(gnutls_session_t session, /* this function sends the client extension data (dnsname) */ if (session->security_parameters.entity == GNUTLS_CLIENT) { - gnutls_ext_priv_data_t epriv; - - ret = _gnutls_hello_ext_get_priv(session, - GNUTLS_EXTENSION_MAX_RECORD_SIZE, - &epriv); - if (ret < 0) { /* it is ok not to have it */ - return 0; - } + if (session->security_parameters.max_record_send_size != + DEFAULT_MAX_RECORD_SIZE) { + p = (uint8_t) + _gnutls_mre_record2num + (session->security_parameters. + max_record_send_size); - if ((intptr_t)epriv != DEFAULT_MAX_RECORD_SIZE) { - p = (uint8_t) _gnutls_mre_record2num((intptr_t)epriv); ret = _gnutls_buffer_append_data(extdata, &p, 1); if (ret < 0) return gnutls_assert_val(ret); @@ -182,34 +160,6 @@ _gnutls_max_record_send_params(gnutls_session_t session, } -static int -_gnutls_max_record_pack(gnutls_ext_priv_data_t epriv, gnutls_buffer_st * ps) -{ - int ret; - - BUFFER_APPEND_NUM(ps, (intptr_t)epriv); - - return 0; - -} - -static int -_gnutls_max_record_unpack(gnutls_buffer_st * ps, - gnutls_ext_priv_data_t * _priv) -{ - gnutls_ext_priv_data_t epriv; - int ret; - - BUFFER_POP_CAST_NUM(ps, epriv); - - *_priv = epriv; - - ret = 0; - error: - return ret; -} - - /* Maps numbers to record sizes according to the * extensions draft. */ @@ -290,7 +240,6 @@ size_t gnutls_record_get_max_size(gnutls_session_t session) ssize_t gnutls_record_set_max_size(gnutls_session_t session, size_t size) { ssize_t new_size; - gnutls_ext_priv_data_t epriv; if (session->security_parameters.entity == GNUTLS_SERVER) return GNUTLS_E_INVALID_REQUEST; @@ -303,11 +252,6 @@ ssize_t gnutls_record_set_max_size(gnutls_session_t session, size_t size) } session->security_parameters.max_record_send_size = size; - epriv = (void *)(intptr_t)size; - - _gnutls_hello_ext_set_priv(session, - GNUTLS_EXTENSION_MAX_RECORD_SIZE, - epriv); return 0; } |