diff options
author | Simon Warta <[email protected]> | 2015-06-29 14:02:37 +0200 |
---|---|---|
committer | Simon Warta <[email protected]> | 2015-06-30 10:38:23 +0200 |
commit | 1de5fc1419add86884df97580d7a2e745ad43bff (patch) | |
tree | 295eafb79cab7843888133abbad07fb983915520 /src/lib/tls | |
parent | 8668ce8753b10e944bdc72b6e66d752759c7e710 (diff) |
More changes for use with debug STL
Diffstat (limited to 'src/lib/tls')
-rw-r--r-- | src/lib/tls/msg_certificate.cpp | 4 | ||||
-rw-r--r-- | src/lib/tls/tls_handshake_io.cpp | 10 | ||||
-rw-r--r-- | src/lib/tls/tls_record.cpp | 4 |
3 files changed, 12 insertions, 6 deletions
diff --git a/src/lib/tls/msg_certificate.cpp b/src/lib/tls/msg_certificate.cpp index 99722c306..f0ccc5328 100644 --- a/src/lib/tls/msg_certificate.cpp +++ b/src/lib/tls/msg_certificate.cpp @@ -41,9 +41,9 @@ Certificate::Certificate(const std::vector<byte>& buf) if(total_size != buf.size() - 3) throw Decoding_Error("Certificate: Message malformed"); - const byte* certs = &buf[3]; + const byte* certs = buf.data() + 3; - while(size_t remaining_bytes = &buf[buf.size()] - certs) + while(size_t remaining_bytes = buf.data() + buf.size() - certs) { if(remaining_bytes < 3) throw Decoding_Error("Certificate: Message malformed"); diff --git a/src/lib/tls/tls_handshake_io.cpp b/src/lib/tls/tls_handshake_io.cpp index d4633becd..6286eab08 100644 --- a/src/lib/tls/tls_handshake_io.cpp +++ b/src/lib/tls/tls_handshake_io.cpp @@ -95,7 +95,10 @@ Stream_Handshake_IO::format(const std::vector<byte>& msg, store_be24(&send_buf[1], buf_size); - copy_mem(&send_buf[4], msg.data(), msg.size()); + if (msg.size() > 0) + { + copy_mem(&send_buf[4], msg.data(), msg.size()); + } return send_buf; } @@ -350,7 +353,10 @@ Datagram_Handshake_IO::format_fragment(const byte fragment[], store_be24(&send_buf[6], frag_offset); store_be24(&send_buf[9], frag_len); - copy_mem(&send_buf[12], fragment, frag_len); + if (frag_len > 0) + { + copy_mem(&send_buf[12], fragment, frag_len); + } return send_buf; } diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp index c384611e9..3ba02f039 100644 --- a/src/lib/tls/tls_record.cpp +++ b/src/lib/tls/tls_record.cpp @@ -491,7 +491,7 @@ size_t read_tls_record(secure_vector<byte>& readbuf, if(epoch == 0) // Unencrypted initial handshake { - record.assign(&readbuf[TLS_HEADER_SIZE], &readbuf[TLS_HEADER_SIZE + record_len]); + record.assign(readbuf.begin() + TLS_HEADER_SIZE, readbuf.begin() + TLS_HEADER_SIZE + record_len); readbuf.clear(); return 0; // got a full record } @@ -578,7 +578,7 @@ size_t read_dtls_record(secure_vector<byte>& readbuf, if(epoch == 0) // Unencrypted initial handshake { - record.assign(&readbuf[DTLS_HEADER_SIZE], &readbuf[DTLS_HEADER_SIZE + record_len]); + record.assign(readbuf.begin() + DTLS_HEADER_SIZE, readbuf.begin() + DTLS_HEADER_SIZE + record_len); readbuf.clear(); return 0; // got a full record } |