diff options
author | Adam Langley <agl@google.com> | 2014-11-18 04:26:55 +0300 |
---|---|---|
committer | Adam Langley <agl@google.com> | 2014-11-19 04:24:46 +0300 |
commit | 69a01608f33ab6fe2c3485d94aef1fe9eacf5364 (patch) | |
tree | 82a6e6cd7402e7a237f03d4d8ca6c3ca76c885d7 /ssl/d1_srvr.c | |
parent | deb52841381fdfa7d73b1855dd36798fbbe7a8bf (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/d1_srvr.c')
-rw-r--r-- | ssl/d1_srvr.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/ssl/d1_srvr.c b/ssl/d1_srvr.c index bf13620a..0bb99b6c 100644 --- a/ssl/d1_srvr.c +++ b/ssl/d1_srvr.c @@ -239,9 +239,15 @@ int dtls1_accept(SSL *s) * the output is sent in a way that TCP likes :-) * ...but not with SCTP :-) */ - if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; } + if (!ssl_init_wbio_buffer(s,1)) { ret= -1; goto end; } + + if (!ssl3_init_finished_mac(s)) + { + OPENSSL_PUT_ERROR(SSL, dtls1_accept, ERR_R_INTERNAL_ERROR); + ret = -1; + goto end; + } - ssl3_init_finished_mac(s); s->state=SSL3_ST_SR_CLNT_HELLO_A; s->ctx->stats.sess_accept++; } @@ -267,7 +273,12 @@ int dtls1_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, dtls1_accept, ERR_R_INTERNAL_ERROR); + ret = -1; + goto end; + } break; case SSL3_ST_SW_HELLO_REQ_C: @@ -301,7 +312,12 @@ int dtls1_accept(SSL *s) s->s3->tmp.next_state=SSL3_ST_SR_CLNT_HELLO_A; /* HelloVerifyRequest resets Finished MAC */ - ssl3_init_finished_mac(s); + if (!ssl3_init_finished_mac(s)) + { + OPENSSL_PUT_ERROR(SSL, dtls1_accept, ERR_R_INTERNAL_ERROR); + ret = -1; + goto end; + } break; |