From d80d7415a399fc9fb3d89b120bb812f617c48238 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Wed, 18 Jun 2014 04:49:41 +0000 Subject: Make sure to always invoke EVP_CIPHER_CTX_cleanup() before returning in the error paths from tls_decrypt_ticket(). ok tedu@ --- lib/libssl/src/ssl/t1_lib.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'lib/libssl') diff --git a/lib/libssl/src/ssl/t1_lib.c b/lib/libssl/src/ssl/t1_lib.c index b780faf603c..054de0ceef1 100644 --- a/lib/libssl/src/ssl/t1_lib.c +++ b/lib/libssl/src/ssl/t1_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: t1_lib.c,v 1.46 2014/06/13 04:29:13 miod Exp $ */ +/* $OpenBSD: t1_lib.c,v 1.47 2014/06/18 04:49:40 miod Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1867,10 +1867,14 @@ tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, unsigned char *nctick = (unsigned char *)etick; int rv = tctx->tlsext_ticket_key_cb(s, nctick, nctick + 16, &ctx, &hctx, 0); - if (rv < 0) + if (rv < 0) { + EVP_CIPHER_CTX_cleanup(&ctx); return -1; - if (rv == 0) + } + if (rv == 0) { + EVP_CIPHER_CTX_cleanup(&ctx); return 2; + } if (rv == 2) renew_ticket = 1; } else { @@ -1895,8 +1899,10 @@ tls_decrypt_ticket(SSL *s, const unsigned char *etick, int eticklen, HMAC_Update(&hctx, etick, eticklen); HMAC_Final(&hctx, tick_hmac, NULL); HMAC_CTX_cleanup(&hctx); - if (CRYPTO_memcmp(tick_hmac, etick + eticklen, mlen)) + if (CRYPTO_memcmp(tick_hmac, etick + eticklen, mlen)) { + EVP_CIPHER_CTX_cleanup(&ctx); return 2; + } /* Attempt to decrypt session data */ /* Move p after IV to start of encrypted ticket, update length */ p = etick + 16 + EVP_CIPHER_CTX_iv_length(&ctx); -- cgit v1.2.3