Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Benjamin <davidben@chromium.org>2015-06-28 08:26:10 +0300
committerAdam Langley <agl@google.com>2015-07-01 22:45:43 +0300
commita8653208ec76d228e889082d5c5e6ce781cdcd8d (patch)
tree042c5519983b5e7fd8141e0249423b243fcabcb1 /ssl/d1_both.c
parentd63307199a9bc39fe86ec46a131d60c694af41f3 (diff)
Add CBB_zero to set a CBB to the zero state.
One tedious thing about using CBB is that you can't safely CBB_cleanup until CBB_init is successful, which breaks the general 'goto err' style of cleanup. This makes it possible: CBB_zero ~ EVP_MD_CTX_init CBB_init ~ EVP_DigestInit CBB_cleanup ~ EVP_MD_CTX_cleanup Change-Id: I085ecc4405715368886dc4de02285a47e7fc4c52 Reviewed-on: https://boringssl-review.googlesource.com/5267 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'ssl/d1_both.c')
-rw-r--r--ssl/d1_both.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/ssl/d1_both.c b/ssl/d1_both.c
index f8724bac..74fc2011 100644
--- a/ssl/d1_both.c
+++ b/ssl/d1_both.c
@@ -592,18 +592,15 @@ long dtls1_get_message(SSL *s, int st1, int stn, int msg_type, long max,
goto err;
}
+ /* Reconstruct the assembled message. */
+ size_t len;
CBB cbb;
+ CBB_zero(&cbb);
if (!BUF_MEM_grow(s->init_buf,
(size_t)frag->msg_header.msg_len +
DTLS1_HM_HEADER_LENGTH) ||
- !CBB_init_fixed(&cbb, (uint8_t *)s->init_buf->data, s->init_buf->max)) {
- OPENSSL_PUT_ERROR(SSL, dtls1_get_message, ERR_R_MALLOC_FAILURE);
- goto err;
- }
-
- /* Reconstruct the assembled message. */
- size_t len;
- if (!CBB_add_u8(&cbb, frag->msg_header.type) ||
+ !CBB_init_fixed(&cbb, (uint8_t *)s->init_buf->data, s->init_buf->max) ||
+ !CBB_add_u8(&cbb, frag->msg_header.type) ||
!CBB_add_u24(&cbb, frag->msg_header.msg_len) ||
!CBB_add_u16(&cbb, frag->msg_header.seq) ||
!CBB_add_u24(&cbb, 0 /* frag_off */) ||
@@ -611,7 +608,7 @@ long dtls1_get_message(SSL *s, int st1, int stn, int msg_type, long max,
!CBB_add_bytes(&cbb, frag->fragment, frag->msg_header.msg_len) ||
!CBB_finish(&cbb, NULL, &len)) {
CBB_cleanup(&cbb);
- OPENSSL_PUT_ERROR(SSL, dtls1_get_message, ERR_R_INTERNAL_ERROR);
+ OPENSSL_PUT_ERROR(SSL, dtls1_get_message, ERR_R_MALLOC_FAILURE);
goto err;
}
assert(len == (size_t)frag->msg_header.msg_len + DTLS1_HM_HEADER_LENGTH);