From 86b9c46552e3f57d558ae8570ed33059e9418153 Mon Sep 17 00:00:00 2001 From: jsing <> Date: Sun, 13 Sep 2015 09:20:19 +0000 Subject: The *_accept() functions increment in_handshake at the start of the function, then decrement it and call a callback on exit from the function. As such, these functions should not return in the middle, otherwise in_handshake is never decremented and the callback never called. ok beck@ "with many sighs" miod@ --- src/lib/libssl/d1_srvr.c | 8 +++++--- src/lib/libssl/s3_srvr.c | 41 ++++++++++++++++++++++++---------------- src/lib/libssl/src/ssl/d1_srvr.c | 8 +++++--- src/lib/libssl/src/ssl/s3_srvr.c | 41 ++++++++++++++++++++++++---------------- 4 files changed, 60 insertions(+), 38 deletions(-) diff --git a/src/lib/libssl/d1_srvr.c b/src/lib/libssl/d1_srvr.c index f5e0ec3e4b..f6664237ae 100644 --- a/src/lib/libssl/d1_srvr.c +++ b/src/lib/libssl/d1_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_srvr.c,v 1.66 2015/09/12 20:51:33 jsing Exp $ */ +/* $OpenBSD: d1_srvr.c,v 1.67 2015/09/13 09:20:19 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -202,7 +202,8 @@ dtls1_accept(SSL *s) if (s->cert == NULL) { SSLerr(SSL_F_DTLS1_ACCEPT, SSL_R_NO_CERTIFICATE_SET); - return (-1); + ret = -1; + goto end; } for (;;) { @@ -224,7 +225,8 @@ dtls1_accept(SSL *s) if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00)) { SSLerr(SSL_F_DTLS1_ACCEPT, ERR_R_INTERNAL_ERROR); - return -1; + ret = -1; + goto end; } s->type = SSL_ST_ACCEPT; diff --git a/src/lib/libssl/s3_srvr.c b/src/lib/libssl/s3_srvr.c index 2fbf063140..cd63422db8 100644 --- a/src/lib/libssl/s3_srvr.c +++ b/src/lib/libssl/s3_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_srvr.c,v 1.121 2015/09/12 16:10:07 doug Exp $ */ +/* $OpenBSD: s3_srvr.c,v 1.122 2015/09/13 09:20:19 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -188,9 +188,9 @@ ssl3_accept(SSL *s) SSL_clear(s); if (s->cert == NULL) { - SSLerr(SSL_F_SSL3_ACCEPT, - SSL_R_NO_CERTIFICATE_SET); - return (-1); + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); + ret = -1; + goto end; } for (;;) { @@ -211,9 +211,9 @@ ssl3_accept(SSL *s) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version >> 8) != 3) { - SSLerr(SSL_F_SSL3_ACCEPT, - ERR_R_INTERNAL_ERROR); - return (-1); + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + ret = -1; + goto end; } s->type = SSL_ST_ACCEPT; @@ -392,9 +392,12 @@ ssl3_accept(SSL *s) skip = 1; s->s3->tmp.cert_request = 0; s->state = SSL3_ST_SW_SRVR_DONE_A; - if (s->s3->handshake_buffer) - if (!tls1_digest_cached_records(s)) - return (-1); + if (s->s3->handshake_buffer) { + if (!tls1_digest_cached_records(s)) { + ret = -1; + goto end; + } + } } else { s->s3->tmp.cert_request = 1; ret = ssl3_send_certificate_request(s); @@ -482,11 +485,14 @@ ssl3_accept(SSL *s) if (!s->s3->handshake_buffer) { SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); - return (-1); + ret = -1; + goto end; } s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; - if (!tls1_digest_cached_records(s)) - return (-1); + if (!tls1_digest_cached_records(s)) { + ret = -1; + goto end; + } } else { int offset = 0; int dgst_num; @@ -501,9 +507,12 @@ ssl3_accept(SSL *s) * CertificateVerify should be generalized. * But it is next step */ - if (s->s3->handshake_buffer) - if (!tls1_digest_cached_records(s)) - return (-1); + if (s->s3->handshake_buffer) { + if (!tls1_digest_cached_records(s)) { + ret = -1; + goto end; + } + } for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) if (s->s3->handshake_dgst[dgst_num]) { diff --git a/src/lib/libssl/src/ssl/d1_srvr.c b/src/lib/libssl/src/ssl/d1_srvr.c index f5e0ec3e4b..f6664237ae 100644 --- a/src/lib/libssl/src/ssl/d1_srvr.c +++ b/src/lib/libssl/src/ssl/d1_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: d1_srvr.c,v 1.66 2015/09/12 20:51:33 jsing Exp $ */ +/* $OpenBSD: d1_srvr.c,v 1.67 2015/09/13 09:20:19 jsing Exp $ */ /* * DTLS implementation written by Nagendra Modadugu * (nagendra@cs.stanford.edu) for the OpenSSL project 2005. @@ -202,7 +202,8 @@ dtls1_accept(SSL *s) if (s->cert == NULL) { SSLerr(SSL_F_DTLS1_ACCEPT, SSL_R_NO_CERTIFICATE_SET); - return (-1); + ret = -1; + goto end; } for (;;) { @@ -224,7 +225,8 @@ dtls1_accept(SSL *s) if ((s->version & 0xff00) != (DTLS1_VERSION & 0xff00)) { SSLerr(SSL_F_DTLS1_ACCEPT, ERR_R_INTERNAL_ERROR); - return -1; + ret = -1; + goto end; } s->type = SSL_ST_ACCEPT; diff --git a/src/lib/libssl/src/ssl/s3_srvr.c b/src/lib/libssl/src/ssl/s3_srvr.c index 2fbf063140..cd63422db8 100644 --- a/src/lib/libssl/src/ssl/s3_srvr.c +++ b/src/lib/libssl/src/ssl/s3_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s3_srvr.c,v 1.121 2015/09/12 16:10:07 doug Exp $ */ +/* $OpenBSD: s3_srvr.c,v 1.122 2015/09/13 09:20:19 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -188,9 +188,9 @@ ssl3_accept(SSL *s) SSL_clear(s); if (s->cert == NULL) { - SSLerr(SSL_F_SSL3_ACCEPT, - SSL_R_NO_CERTIFICATE_SET); - return (-1); + SSLerr(SSL_F_SSL3_ACCEPT, SSL_R_NO_CERTIFICATE_SET); + ret = -1; + goto end; } for (;;) { @@ -211,9 +211,9 @@ ssl3_accept(SSL *s) cb(s, SSL_CB_HANDSHAKE_START, 1); if ((s->version >> 8) != 3) { - SSLerr(SSL_F_SSL3_ACCEPT, - ERR_R_INTERNAL_ERROR); - return (-1); + SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); + ret = -1; + goto end; } s->type = SSL_ST_ACCEPT; @@ -392,9 +392,12 @@ ssl3_accept(SSL *s) skip = 1; s->s3->tmp.cert_request = 0; s->state = SSL3_ST_SW_SRVR_DONE_A; - if (s->s3->handshake_buffer) - if (!tls1_digest_cached_records(s)) - return (-1); + if (s->s3->handshake_buffer) { + if (!tls1_digest_cached_records(s)) { + ret = -1; + goto end; + } + } } else { s->s3->tmp.cert_request = 1; ret = ssl3_send_certificate_request(s); @@ -482,11 +485,14 @@ ssl3_accept(SSL *s) if (!s->s3->handshake_buffer) { SSLerr(SSL_F_SSL3_ACCEPT, ERR_R_INTERNAL_ERROR); - return (-1); + ret = -1; + goto end; } s->s3->flags |= TLS1_FLAGS_KEEP_HANDSHAKE; - if (!tls1_digest_cached_records(s)) - return (-1); + if (!tls1_digest_cached_records(s)) { + ret = -1; + goto end; + } } else { int offset = 0; int dgst_num; @@ -501,9 +507,12 @@ ssl3_accept(SSL *s) * CertificateVerify should be generalized. * But it is next step */ - if (s->s3->handshake_buffer) - if (!tls1_digest_cached_records(s)) - return (-1); + if (s->s3->handshake_buffer) { + if (!tls1_digest_cached_records(s)) { + ret = -1; + goto end; + } + } for (dgst_num = 0; dgst_num < SSL_MAX_DIGEST; dgst_num++) if (s->s3->handshake_dgst[dgst_num]) { -- cgit v1.2.3-55-g6feb