diff options
author | Matt Caswell <matt@openssl.org> | 2016-09-29 23:28:29 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-10-03 16:25:48 +0100 |
commit | 7cea05dcc7f6f74a18d48102008d53ea9a42c297 (patch) | |
tree | 062b75919f3bf53e6e4c69ebd1270f094aae756d /ssl/statem/statem_dtls.c | |
parent | b7c9aa645e4eddf5d198d2b20f1c6a74ab96f98e (diff) | |
download | openssl-new-7cea05dcc7f6f74a18d48102008d53ea9a42c297.tar.gz |
Move init of the WPACKET into write_state_machine()
Instead of initialising, finishing and cleaning up the WPACKET in every
message construction function, we should do it once in
write_state_machine().
Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'ssl/statem/statem_dtls.c')
-rw-r--r-- | ssl/statem/statem_dtls.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/ssl/statem/statem_dtls.c b/ssl/statem/statem_dtls.c index 0328ab7def..cc016dac25 100644 --- a/ssl/statem/statem_dtls.c +++ b/ssl/statem/statem_dtls.c @@ -872,12 +872,9 @@ static int dtls_get_reassembled_message(SSL *s, long *len) * ssl->session->read_compression assign * ssl->session->read_hash assign */ -int dtls_construct_change_cipher_spec(SSL *s) +int dtls_construct_change_cipher_spec(SSL *s, WPACKET *pkt) { - WPACKET pkt; - - if (!WPACKET_init(&pkt, s->init_buf) - || !WPACKET_put_bytes_u8(&pkt, SSL3_MT_CCS)) { + if (!WPACKET_put_bytes_u8(pkt, SSL3_MT_CCS)) { SSLerr(SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); goto err; } @@ -888,7 +885,7 @@ int dtls_construct_change_cipher_spec(SSL *s) if (s->version == DTLS1_BAD_VER) { s->d1->next_handshake_write_seq++; - if (!WPACKET_put_bytes_u16(&pkt, s->d1->handshake_write_seq)) { + if (!WPACKET_put_bytes_u16(pkt, s->d1->handshake_write_seq)) { SSLerr(SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); goto err; } @@ -896,11 +893,6 @@ int dtls_construct_change_cipher_spec(SSL *s) s->init_num += 2; } - if (!WPACKET_finish(&pkt)) { - SSLerr(SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC, ERR_R_INTERNAL_ERROR); - goto err; - } - s->init_off = 0; dtls1_set_message_header_int(s, SSL3_MT_CCS, 0, @@ -913,11 +905,9 @@ int dtls_construct_change_cipher_spec(SSL *s) } return 1; + err: - WPACKET_cleanup(&pkt); - ossl_statem_set_error(s); ssl3_send_alert(s, SSL3_AL_FATAL, SSL_AD_INTERNAL_ERROR); - return 0; } @@ -1235,8 +1225,7 @@ int dtls1_close_construct_packet(SSL *s, WPACKET *pkt) if (!WPACKET_close(pkt) || !WPACKET_get_length(pkt, &msglen) - || msglen > INT_MAX - || !WPACKET_finish(pkt)) + || msglen > INT_MAX) return 0; s->d1->w_msg_hdr.msg_len = msglen - DTLS1_HM_HEADER_LENGTH; s->d1->w_msg_hdr.frag_len = msglen - DTLS1_HM_HEADER_LENGTH; |