050853a3d1a63e88042d23aaf079cdc10b9606ae
[openwrt/openwrt.git] / package / libs / openssl / patches / 230-eng_devcrypto-close-session-on-cleanup-not-final.patch
1 From 5378c582c8d3f1130b17abb2950bfd09cde099c6 Mon Sep 17 00:00:00 2001
2 From: Eneas U de Queiroz <cote2004-github@yahoo.com>
3 Date: Mon, 5 Nov 2018 15:59:44 -0200
4 Subject: [PATCH 4/7] eng_devcrypto: close session on cleanup, not final
5
6 Close the session in digest_cleanup instead of digest_final. A failure
7 in closing the session does not mean a previous successful digest final
8 has failed as well.
9
10 Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
11
12 Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
13 Reviewed-by: Richard Levitte <levitte@openssl.org>
14 (Merged from https://github.com/openssl/openssl/pull/7585)
15
16 (cherry picked from commit a67203a19d379a8cc8b369587c60c46eb4e19014)
17
18 --- a/crypto/engine/eng_devcrypto.c
19 +++ b/crypto/engine/eng_devcrypto.c
20 @@ -461,10 +461,6 @@ static int digest_final(EVP_MD_CTX *ctx,
21 SYSerr(SYS_F_IOCTL, errno);
22 return 0;
23 }
24 - if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
25 - SYSerr(SYS_F_IOCTL, errno);
26 - return 0;
27 - }
28
29 return 1;
30 }
31 @@ -496,6 +492,15 @@ static int digest_copy(EVP_MD_CTX *to, c
32
33 static int digest_cleanup(EVP_MD_CTX *ctx)
34 {
35 + struct digest_ctx *digest_ctx =
36 + (struct digest_ctx *)EVP_MD_CTX_md_data(ctx);
37 +
38 + if (digest_ctx == NULL)
39 + return 1;
40 + if (ioctl(cfd, CIOCFSESSION, &digest_ctx->sess.ses) < 0) {
41 + SYSerr(SYS_F_IOCTL, errno);
42 + return 0;
43 + }
44 return 1;
45 }
46