ssl/s3_enc.c: fix logical errors in ssl3_final_finish_mac.
authorAndy Polyakov <appro@openssl.org>
Fri, 12 Oct 2018 20:17:51 +0000 (22:17 +0200)
committerAndy Polyakov <appro@openssl.org>
Wed, 17 Oct 2018 11:58:24 +0000 (13:58 +0200)
(back-port of commit 7d0effeacbb50b12bfc24df7614d7cf5c8686f51)

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7392)

ssl/s3_enc.c

index e08857df9b75a96c00a6a26216c4f1fa47e3fcf8..89b773946675533b65b38e4716147f4724e9b76f 100644 (file)
@@ -404,13 +404,14 @@ int ssl3_final_finish_mac(SSL *s, const char *sender, int len, unsigned char *p)
     }
     if (!EVP_MD_CTX_copy_ex(ctx, s->s3->handshake_dgst)) {
         SSLerr(SSL_F_SSL3_FINAL_FINISH_MAC, ERR_R_INTERNAL_ERROR);
-        return 0;
+        ret = 0;
+        goto err;
     }
 
     ret = EVP_MD_CTX_size(ctx);
     if (ret < 0) {
-        EVP_MD_CTX_reset(ctx);
-        return 0;
+        ret = 0;
+        goto err;
     }
 
     if ((sender != NULL && EVP_DigestUpdate(ctx, sender, len) <= 0)
@@ -422,6 +423,7 @@ int ssl3_final_finish_mac(SSL *s, const char *sender, int len, unsigned char *p)
         ret = 0;
     }
 
+ err:
     EVP_MD_CTX_free(ctx);
 
     return ret;