diff options
author | lloyd <[email protected]> | 2012-09-06 19:03:08 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-09-06 19:03:08 +0000 |
commit | a0586a0b542ebf08b58c371eae7c7b1cacf84ecc (patch) | |
tree | f838cb41754e24fef432592f73bb3d090bad2f09 | |
parent | 263bc1d72b059a77b7b06e00cbbaf38311965a37 (diff) |
Inline current_protocol_version, fix fragment limit check
-rw-r--r-- | src/tls/tls_channel.cpp | 21 | ||||
-rw-r--r-- | src/tls/tls_channel.h | 3 |
2 files changed, 13 insertions, 11 deletions
diff --git a/src/tls/tls_channel.cpp b/src/tls/tls_channel.cpp index 3a8786491..4696a49d5 100644 --- a/src/tls/tls_channel.cpp +++ b/src/tls/tls_channel.cpp @@ -44,6 +44,7 @@ Handshake_State& Channel::create_handshake_state() throw Internal_Error("create_handshake_state called during handshake"); m_state.reset(new_handshake_state()); + return *m_state.get(); } @@ -63,11 +64,6 @@ void Channel::set_protocol_version(Protocol_Version version) m_state->set_version(version); } -Protocol_Version Channel::current_protocol_version() const - { - return m_current_version; - } - void Channel::set_maximum_fragment_size(size_t max_fragment) { if(max_fragment == 0) @@ -357,19 +353,24 @@ void Channel::send_record(byte record_type, const std::vector<byte>& record) void Channel::write_record(byte record_type, const byte input[], size_t length) { - if(length >= m_max_fragment) + if(length > m_max_fragment) throw Internal_Error("Record is larger than allowed fragment size"); - Protocol_Version version = current_protocol_version(); - if(!version.valid()) - version = m_state->handshake_io().initial_record_version(); + Protocol_Version record_version = current_protocol_version(); + if(!record_version.valid()) + { + BOTAN_ASSERT(m_state && !m_state->server_hello(), + "In first record of client connection"); + + record_version = m_state->handshake_io().initial_record_version(); + } const size_t written = TLS::write_record(m_writebuf, record_type, input, length, m_write_seq_no, - version, + record_version, m_write_cipherstate.get(), m_rng); diff --git a/src/tls/tls_channel.h b/src/tls/tls_channel.h index fc838afcf..d9c1ab34b 100644 --- a/src/tls/tls_channel.h +++ b/src/tls/tls_channel.h @@ -120,7 +120,8 @@ class BOTAN_DLL Channel void set_protocol_version(Protocol_Version version); - Protocol_Version current_protocol_version() const; + Protocol_Version current_protocol_version() const + { return m_current_version; } void set_maximum_fragment_size(size_t maximum); |