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:
authorAdam Langley <agl@google.com>2014-11-18 04:26:55 +0300
committerAdam Langley <agl@google.com>2014-11-19 04:24:46 +0300
commit69a01608f33ab6fe2c3485d94aef1fe9eacf5364 (patch)
tree82a6e6cd7402e7a237f03d4d8ca6c3ca76c885d7 /ssl/s3_srvr.c
parentdeb52841381fdfa7d73b1855dd36798fbbe7a8bf (diff)
Add malloc failure tests.
This commit fixes a number of crashes caused by malloc failures. They were found using the -malloc-test=0 option to runner.go which runs tests many times, causing a different allocation call to fail in each case. (This test only works on Linux and only looks for crashes caused by allocation failures, not memory leaks or other errors.) This is not the complete set of crashes! More can be found by collecting core dumps from running with -malloc-test=0. Change-Id: Ia61d19f51e373bccb7bc604642c51e043a74bd83 Reviewed-on: https://boringssl-review.googlesource.com/2320 Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'ssl/s3_srvr.c')
-rw-r--r--ssl/s3_srvr.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/ssl/s3_srvr.c b/ssl/s3_srvr.c
index 24967836..c7bc58bc 100644
--- a/ssl/s3_srvr.c
+++ b/ssl/s3_srvr.c
@@ -294,7 +294,12 @@ int ssl3_accept(SSL *s)
*/
if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; }
- ssl3_init_finished_mac(s);
+ if (!ssl3_init_finished_mac(s))
+ {
+ OPENSSL_PUT_ERROR(SSL, ssl3_accept, ERR_R_INTERNAL_ERROR);
+ ret = -1;
+ goto end;
+ }
s->state=SSL3_ST_SR_CLNT_HELLO_A;
s->ctx->stats.sess_accept++;
}
@@ -329,7 +334,12 @@ int ssl3_accept(SSL *s)
s->state=SSL3_ST_SW_FLUSH;
s->init_num=0;
- ssl3_init_finished_mac(s);
+ if (!ssl3_init_finished_mac(s))
+ {
+ OPENSSL_PUT_ERROR(SSL, ssl3_accept, ERR_R_INTERNAL_ERROR);
+ ret = -1;
+ goto end;
+ }
break;
case SSL3_ST_SW_HELLO_REQ_C:
@@ -2578,16 +2588,22 @@ int ssl3_send_new_session_ticket(SSL *s)
&hctx, 1) < 0)
{
OPENSSL_free(session);
+ EVP_CIPHER_CTX_cleanup(&ctx);
+ HMAC_CTX_cleanup(&hctx);
return -1;
}
}
else
{
RAND_pseudo_bytes(iv, 16);
- EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL,
- tctx->tlsext_tick_aes_key, iv);
- HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16,
- tlsext_tick_md(), NULL);
+ if (!EVP_EncryptInit_ex(&ctx, EVP_aes_128_cbc(), NULL, tctx->tlsext_tick_aes_key, iv) ||
+ !HMAC_Init_ex(&hctx, tctx->tlsext_tick_hmac_key, 16, tlsext_tick_md(), NULL))
+ {
+ OPENSSL_free(session);
+ EVP_CIPHER_CTX_cleanup(&ctx);
+ HMAC_CTX_cleanup(&hctx);
+ return -1;
+ }
memcpy(key_name, tctx->tlsext_tick_key_name, 16);
}