From eea15f69e1ca11787ba8bf21a6f275c59fda1eb9 Mon Sep 17 00:00:00 2001 From: Michael Hinz Date: Fri, 3 Nov 2023 14:17:39 +0100 Subject: [PATCH 01/10] Fix documentation regarding KMAC sizes As per recommendation by jfinkhaeuser, this documents the defaults for KMAC-128 as 32 and for KMAC-256 as 64. The code already accomodates for these values, so no changes are needed there. Fixes #22381 CLA: trivial Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell Reviewed-by: Shane Lontis Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/22614) (cherry picked from commit 56d1ab3b6c7468ce0f534f09e305a539101f9c3d) Signed-off-by: fly2x --- doc/man7/EVP_MAC-KMAC.pod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man7/EVP_MAC-KMAC.pod b/doc/man7/EVP_MAC-KMAC.pod index 1065c166db..dc67c66336 100644 --- a/doc/man7/EVP_MAC-KMAC.pod +++ b/doc/man7/EVP_MAC-KMAC.pod @@ -51,7 +51,7 @@ It is an optional value with a length of at most 512 bytes, and is empty by defa =item "size" (B) Sets the MAC size. -By default, it is 16 for C and 32 for C. +By default, it is 32 for C and 64 for C. =item "block-size" (B) -- Gitee From 15e1fe55a79dc9931885e3ea6427d8614b22f7d6 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Fri, 20 Oct 2023 09:18:19 +0200 Subject: [PATCH 02/10] Make DH_check_pub_key() and DH_generate_key() safer yet We already check for an excessively large P in DH_generate_key(), but not in DH_check_pub_key(), and none of them check for an excessively large Q. This change adds all the missing excessive size checks of P and Q. It's to be noted that behaviours surrounding excessively sized P and Q differ. DH_check() raises an error on the excessively sized P, but only sets a flag for the excessively sized Q. This behaviour is mimicked in DH_check_pub_key(). Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/22518) (cherry picked from commit ddeb4b6c6d527e54ce9a99cba785c0f7776e54b6) Signed-off-by: fly2x --- crypto/dh/dh_check.c | 12 ++++++++++++ crypto/dh/dh_err.c | 3 ++- crypto/dh/dh_key.c | 12 ++++++++++++ crypto/err/openssl.txt | 1 + include/crypto/dherr.h | 2 +- include/openssl/dh.h | 6 +++--- include/openssl/dherr.h | 3 ++- 7 files changed, 33 insertions(+), 6 deletions(-) diff --git a/crypto/dh/dh_check.c b/crypto/dh/dh_check.c index 7ba2beae7f..e20eb62081 100644 --- a/crypto/dh/dh_check.c +++ b/crypto/dh/dh_check.c @@ -249,6 +249,18 @@ int DH_check_pub_key_ex(const DH *dh, const BIGNUM *pub_key) */ int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *ret) { + /* Don't do any checks at all with an excessively large modulus */ + if (BN_num_bits(dh->params.p) > OPENSSL_DH_CHECK_MAX_MODULUS_BITS) { + ERR_raise(ERR_LIB_DH, DH_R_MODULUS_TOO_LARGE); + *ret = DH_MODULUS_TOO_LARGE | DH_CHECK_PUBKEY_INVALID; + return 0; + } + + if (dh->params.q != NULL && BN_ucmp(dh->params.p, dh->params.q) < 0) { + *ret |= DH_CHECK_INVALID_Q_VALUE | DH_CHECK_PUBKEY_INVALID; + return 1; + } + return ossl_ffc_validate_public_key(&dh->params, pub_key, ret); } diff --git a/crypto/dh/dh_err.c b/crypto/dh/dh_err.c index 4152397426..f76ac0dd14 100644 --- a/crypto/dh/dh_err.c +++ b/crypto/dh/dh_err.c @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -54,6 +54,7 @@ static const ERR_STRING_DATA DH_str_reasons[] = { {ERR_PACK(ERR_LIB_DH, 0, DH_R_PARAMETER_ENCODING_ERROR), "parameter encoding error"}, {ERR_PACK(ERR_LIB_DH, 0, DH_R_PEER_KEY_ERROR), "peer key error"}, + {ERR_PACK(ERR_LIB_DH, 0, DH_R_Q_TOO_LARGE), "q too large"}, {ERR_PACK(ERR_LIB_DH, 0, DH_R_SHARED_INFO_ERROR), "shared info error"}, {ERR_PACK(ERR_LIB_DH, 0, DH_R_UNABLE_TO_CHECK_GENERATOR), "unable to check generator"}, diff --git a/crypto/dh/dh_key.c b/crypto/dh/dh_key.c index d84ea99241..afc49f5cdc 100644 --- a/crypto/dh/dh_key.c +++ b/crypto/dh/dh_key.c @@ -49,6 +49,12 @@ int ossl_dh_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) goto err; } + if (dh->params.q != NULL + && BN_num_bits(dh->params.q) > OPENSSL_DH_MAX_MODULUS_BITS) { + ERR_raise(ERR_LIB_DH, DH_R_Q_TOO_LARGE); + goto err; + } + if (BN_num_bits(dh->params.p) < DH_MIN_MODULUS_BITS) { ERR_raise(ERR_LIB_DH, DH_R_MODULUS_TOO_SMALL); return 0; @@ -267,6 +273,12 @@ static int generate_key(DH *dh) return 0; } + if (dh->params.q != NULL + && BN_num_bits(dh->params.q) > OPENSSL_DH_MAX_MODULUS_BITS) { + ERR_raise(ERR_LIB_DH, DH_R_Q_TOO_LARGE); + return 0; + } + if (BN_num_bits(dh->params.p) < DH_MIN_MODULUS_BITS) { ERR_raise(ERR_LIB_DH, DH_R_MODULUS_TOO_SMALL); return 0; diff --git a/crypto/err/openssl.txt b/crypto/err/openssl.txt index e51504b7ab..36de321b74 100644 --- a/crypto/err/openssl.txt +++ b/crypto/err/openssl.txt @@ -500,6 +500,7 @@ DH_R_NO_PARAMETERS_SET:107:no parameters set DH_R_NO_PRIVATE_VALUE:100:no private value DH_R_PARAMETER_ENCODING_ERROR:105:parameter encoding error DH_R_PEER_KEY_ERROR:111:peer key error +DH_R_Q_TOO_LARGE:130:q too large DH_R_SHARED_INFO_ERROR:113:shared info error DH_R_UNABLE_TO_CHECK_GENERATOR:121:unable to check generator DSA_R_BAD_FFC_PARAMETERS:114:bad ffc parameters diff --git a/include/crypto/dherr.h b/include/crypto/dherr.h index bb24d131eb..519327f795 100644 --- a/include/crypto/dherr.h +++ b/include/crypto/dherr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2020-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy diff --git a/include/openssl/dh.h b/include/openssl/dh.h index 6533260f20..50e0cf54be 100644 --- a/include/openssl/dh.h +++ b/include/openssl/dh.h @@ -141,7 +141,7 @@ DECLARE_ASN1_ITEM(DHparams) # define DH_GENERATOR_3 3 # define DH_GENERATOR_5 5 -/* DH_check error codes */ +/* DH_check error codes, some of them shared with DH_check_pub_key */ /* * NB: These values must align with the equivalently named macros in * internal/ffc.h. @@ -151,10 +151,10 @@ DECLARE_ASN1_ITEM(DHparams) # define DH_UNABLE_TO_CHECK_GENERATOR 0x04 # define DH_NOT_SUITABLE_GENERATOR 0x08 # define DH_CHECK_Q_NOT_PRIME 0x10 -# define DH_CHECK_INVALID_Q_VALUE 0x20 +# define DH_CHECK_INVALID_Q_VALUE 0x20 /* +DH_check_pub_key */ # define DH_CHECK_INVALID_J_VALUE 0x40 # define DH_MODULUS_TOO_SMALL 0x80 -# define DH_MODULUS_TOO_LARGE 0x100 +# define DH_MODULUS_TOO_LARGE 0x100 /* +DH_check_pub_key */ /* DH_check_pub_key error codes */ # define DH_CHECK_PUBKEY_TOO_SMALL 0x01 diff --git a/include/openssl/dherr.h b/include/openssl/dherr.h index 5d2a762a96..074a70145f 100644 --- a/include/openssl/dherr.h +++ b/include/openssl/dherr.h @@ -1,6 +1,6 @@ /* * Generated by util/mkerr.pl DO NOT EDIT - * Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved. * * Licensed under the Apache License 2.0 (the "License"). You may not use * this file except in compliance with the License. You can obtain a copy @@ -50,6 +50,7 @@ # define DH_R_NO_PRIVATE_VALUE 100 # define DH_R_PARAMETER_ENCODING_ERROR 105 # define DH_R_PEER_KEY_ERROR 111 +# define DH_R_Q_TOO_LARGE 130 # define DH_R_SHARED_INFO_ERROR 113 # define DH_R_UNABLE_TO_CHECK_GENERATOR 121 -- Gitee From 04ed2932965c64998e80739c10f1644f3ced477a Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Fri, 20 Oct 2023 09:24:01 +0200 Subject: [PATCH 03/10] Fix conflicts between DH check flags and FFC check flags There are comments in include/openssl/dh.h and include/internal/ffc.h that they must be aligned with each other, and yet, clashes have been introduced. The simplest fix is to move the offending FFC flags out of the way, as they are indeed internal and shouldn't affect any public interface, apart from those that are aligned with the DH flags, which are public. Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/22518) (cherry picked from commit 3629ce9c4cb638d9458d8febd21659920903a749) Signed-off-by: fly2x --- include/internal/ffc.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/internal/ffc.h b/include/internal/ffc.h index c4f090875f..e96f08d68e 100644 --- a/include/internal/ffc.h +++ b/include/internal/ffc.h @@ -58,8 +58,11 @@ # define FFC_CHECK_INVALID_Q_VALUE 0x00020 # define FFC_CHECK_INVALID_J_VALUE 0x00040 -# define FFC_CHECK_BAD_LN_PAIR 0x00080 -# define FFC_CHECK_INVALID_SEED_SIZE 0x00100 +/* + * 0x80, 0x100 reserved by include/openssl/dh.h with check bits that are not + * relevant for FFC. + */ + # define FFC_CHECK_MISSING_SEED_OR_COUNTER 0x00200 # define FFC_CHECK_INVALID_G 0x00400 # define FFC_CHECK_INVALID_PQ 0x00800 @@ -68,6 +71,8 @@ # define FFC_CHECK_Q_MISMATCH 0x04000 # define FFC_CHECK_G_MISMATCH 0x08000 # define FFC_CHECK_COUNTER_MISMATCH 0x10000 +# define FFC_CHECK_BAD_LN_PAIR 0x20000 +# define FFC_CHECK_INVALID_SEED_SIZE 0x40000 /* Validation Return codes */ # define FFC_ERROR_PUBKEY_TOO_SMALL 0x01 -- Gitee From 2322e2b06774b24f06c94bcf36fd645fe0fa52cb Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Mon, 6 Nov 2023 10:53:46 +0100 Subject: [PATCH 04/10] Use proper KDF SS parameter name Reviewed-by: Matt Caswell Reviewed-by: Paul Dale Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/22636) (cherry picked from commit 1c6a37975495dd633847ff0c07747fae272d5e4d) Signed-off-by: fly2x --- doc/man7/EVP_KDF-SS.pod | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/man7/EVP_KDF-SS.pod b/doc/man7/EVP_KDF-SS.pod index 7f158e4216..c8d19691a7 100644 --- a/doc/man7/EVP_KDF-SS.pod +++ b/doc/man7/EVP_KDF-SS.pod @@ -53,7 +53,7 @@ This parameter is ignored for KMAC. These parameters work as described in L. -=item "key" (B) +=item "key" (B) This parameter set the shared secret that is used for key derivation. @@ -116,7 +116,7 @@ fixedinfo value "label" and salt "salt": SN_hmac, strlen(SN_hmac)); *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_DIGEST, SN_sha256, strlen(SN_sha256)); - *p++ = OSSL_PARAM_construct_octet_string(EVP_KDF_CTRL_SET_KEY, + *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET, "secret", (size_t)6); *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, "label", (size_t)5); @@ -143,7 +143,7 @@ fixedinfo value "label", salt of "salt" and KMAC outlen of 20: *p++ = OSSL_PARAM_construct_utf8_string(OSSL_KDF_PARAM_MAC, SN_kmac128, strlen(SN_kmac128)); - *p++ = OSSL_PARAM_construct_octet_string(EVP_KDF_CTRL_SET_KEY, + *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_SECRET, "secret", (size_t)6); *p++ = OSSL_PARAM_construct_octet_string(OSSL_KDF_PARAM_INFO, "label", (size_t)5); -- Gitee From 9e99bcec5e0c02c37e186ad8d7fd4aa9ad7cdd59 Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 6 Nov 2023 11:03:05 +0100 Subject: [PATCH 05/10] Fix a possible memory leak in custom_ext_add Reviewed-by: Hugo Landau Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/22639) (cherry picked from commit bd864f058c495d97e42007128d62f7fb19ae1818) Signed-off-by: fly2x --- ssl/statem/extensions_cust.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ssl/statem/extensions_cust.c b/ssl/statem/extensions_cust.c index 401a4c5c76..73b82fc7de 100644 --- a/ssl/statem/extensions_cust.c +++ b/ssl/statem/extensions_cust.c @@ -220,6 +220,8 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx, || !WPACKET_start_sub_packet_u16(pkt) || (outlen > 0 && !WPACKET_memcpy(pkt, out, outlen)) || !WPACKET_close(pkt)) { + if (meth->free_cb != NULL) + meth->free_cb(s, meth->ext_type, context, out, meth->add_arg); SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return 0; } @@ -228,6 +230,9 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx, * We can't send duplicates: code logic should prevent this. */ if (!ossl_assert((meth->ext_flags & SSL_EXT_FLAG_SENT) == 0)) { + if (meth->free_cb != NULL) + meth->free_cb(s, meth->ext_type, context, out, + meth->add_arg); SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR); return 0; } -- Gitee From 4afadcfc327d825247dc2f06f6ed2ff00a5a2682 Mon Sep 17 00:00:00 2001 From: "Matthias St. Pierre" Date: Wed, 25 Oct 2023 11:05:58 +0200 Subject: [PATCH 06/10] apps/rehash.c: avoid printf format warning [-Wformat] The `aarch64-linux-android33-clang` cross-compiler (v14.0.6) complains twice about an unsupported '%n' format specifier, preventing a successful `--strict-warnings` build: error: '%n' specifier not supported on this platform [-Werror,-Wformat] BIO_snprintf(buf, buflen, "%s%s%n%08x.%s%d", This is a false positive, because BIO_snprintf() implements its own format parsing (which is implemented in the _dopr() function). This commit fixes the problem by rewriting the code to dispense with the dubious '%n' format specifier. As a side-effect, the code becomes a little bit more comprehensible and self-explaining. Reviewed-by: David von Oheimb Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22511) (cherry picked from commit ec0d22fe1571508c08b714715cfdb6ac60c53f78) Signed-off-by: fly2x --- apps/rehash.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/apps/rehash.c b/apps/rehash.c index 5c6d5340be..9696aa9f4e 100644 --- a/apps/rehash.c +++ b/apps/rehash.c @@ -355,9 +355,9 @@ static int do_dir(const char *dirname, enum Hash h) OPENSSL_DIR_CTX *d = NULL; struct stat st; unsigned char idmask[MAX_COLLISIONS / 8]; - int n, numfiles, nextid, buflen, errs = 0; + int n, numfiles, nextid, dirlen, buflen, errs = 0; size_t i; - const char *pathsep; + const char *pathsep = ""; const char *filename; char *buf, *copy = NULL; STACK_OF(OPENSSL_STRING) *files = NULL; @@ -366,9 +366,12 @@ static int do_dir(const char *dirname, enum Hash h) BIO_printf(bio_err, "Skipping %s, can't write\n", dirname); return 1; } - buflen = strlen(dirname); - pathsep = (buflen && !ends_with_dirsep(dirname)) ? "/": ""; - buflen += NAME_MAX + 1 + 1; + dirlen = strlen(dirname); + if (dirlen != 0 && !ends_with_dirsep(dirname)) { + pathsep = "/"; + dirlen++; + } + buflen = dirlen + NAME_MAX + 1; buf = app_malloc(buflen, "filename buffer"); if (verbose) @@ -427,12 +430,12 @@ static int do_dir(const char *dirname, enum Hash h) while (bit_isset(idmask, nextid)) nextid++; - BIO_snprintf(buf, buflen, "%s%s%n%08x.%s%d", - dirname, pathsep, &n, bp->hash, + BIO_snprintf(buf, buflen, "%s%s%08x.%s%d", + dirname, pathsep, bp->hash, suffixes[bp->type], nextid); if (verbose) BIO_printf(bio_out, "link %s -> %s\n", - ep->filename, &buf[n]); + ep->filename, &buf[dirlen]); if (unlink(buf) < 0 && errno != ENOENT) { BIO_printf(bio_err, "%s: Can't unlink %s, %s\n", @@ -449,12 +452,12 @@ static int do_dir(const char *dirname, enum Hash h) bit_set(idmask, nextid); } else if (remove_links) { /* Link to be deleted */ - BIO_snprintf(buf, buflen, "%s%s%n%08x.%s%d", - dirname, pathsep, &n, bp->hash, + BIO_snprintf(buf, buflen, "%s%s%08x.%s%d", + dirname, pathsep, bp->hash, suffixes[bp->type], ep->old_id); if (verbose) BIO_printf(bio_out, "unlink %s\n", - &buf[n]); + &buf[dirlen]); if (unlink(buf) < 0 && errno != ENOENT) { BIO_printf(bio_err, "%s: Can't unlink %s, %s\n", -- Gitee From 328c2976f73c78cd8b89ed6788dcf19d8d2fb8cf Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Tue, 7 Nov 2023 15:22:00 +0100 Subject: [PATCH 07/10] Add CHANGES.md and NEWS.md entry for CVE-2023-5678 Reviewed-by: Richard Levitte Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/22647) (cherry picked from commit 4ee71b4c302a06c24b46a5def1cff2096bd57f0b) Signed-off-by: fly2x --- CHANGES.md | 15 ++++++++++++++- NEWS.md | 4 +++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index fad0e559aa..b5bea316f6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -30,7 +30,19 @@ breaking changes, and mappings for the large list of deprecated functions. ### Changes between 3.0.12 and 3.0.13 [xx XXX xxxx] - * none yet + * Fix excessive time spent in DH check / generation with large Q parameter + value. + + Applications that use the functions DH_generate_key() to generate an + X9.42 DH key may experience long delays. Likewise, applications that use + DH_check_pub_key(), DH_check_pub_key_ex() or EVP_PKEY_public_check() + to check an X9.42 DH key or X9.42 DH parameters may experience long delays. + Where the key or parameters that are being checked have been obtained from + an untrusted source this may lead to a Denial of Service. + + ([CVE-2023-5678]) + + *Richard Levitte* ### Changes between 3.0.11 and 3.0.12 [24 Oct 2023] @@ -19744,6 +19756,7 @@ ndif +[CVE-2023-5678]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-5678 [CVE-2023-5363]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-5363 [CVE-2023-4807]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-4807 [CVE-2023-3817]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-3817 diff --git a/NEWS.md b/NEWS.md index 1d1bda963c..9162f3ce4e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,7 +20,8 @@ OpenSSL 3.0 ### Major changes between OpenSSL 3.0.12 and OpenSSL 3.0.13 [under development] - * none + * Fix excessive time spent in DH check / generation with large Q parameter + value ([CVE-2023-5678]) ### Major changes between OpenSSL 3.0.11 and OpenSSL 3.0.12 [24 Oct 2023] @@ -1462,6 +1463,7 @@ OpenSSL 0.9.x +[CVE-2023-5678]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-5678 [CVE-2023-5363]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-5363 [CVE-2023-4807]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-4807 [CVE-2023-3817]: https://www.openssl.org/news/vulnerabilities.html#CVE-2023-3817 -- Gitee From 1e3ed463934dd0c0012109e8e97fe2984652abae Mon Sep 17 00:00:00 2001 From: Bernd Edlinger Date: Mon, 6 Nov 2023 10:44:27 +0100 Subject: [PATCH 08/10] Fix a possible memory leak of ssl->s3.tmp.psk Reviewed-by: Matt Caswell Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/22637) (cherry picked from commit a2b1ab6100d5f0fb50b61d241471eea087415632) Signed-off-by: fly2x --- ssl/s3_lib.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 78d4f04056..460b84325d 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -3365,6 +3365,10 @@ void ssl3_free(SSL *s) OPENSSL_free(s->s3.alpn_selected); OPENSSL_free(s->s3.alpn_proposed); +#ifndef OPENSSL_NO_PSK + OPENSSL_free(sc->s3.tmp.psk); +#endif + #ifndef OPENSSL_NO_SRP ssl_srp_ctx_free_intern(s); #endif -- Gitee From cddd45446cb7c534c6e923603ddfb4529326f8f3 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Thu, 9 Nov 2023 16:59:40 +0000 Subject: [PATCH 09/10] Fix a bad backport This is causing compilation failure Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22682) (cherry picked from commit 2fd4fd35bf906290a9c14b81f16e7ae01d297122) Signed-off-by: fly2x --- ssl/s3_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 460b84325d..bcfe57b46f 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -3366,7 +3366,7 @@ void ssl3_free(SSL *s) OPENSSL_free(s->s3.alpn_proposed); #ifndef OPENSSL_NO_PSK - OPENSSL_free(sc->s3.tmp.psk); + OPENSSL_free(s->s3.tmp.psk); #endif #ifndef OPENSSL_NO_SRP -- Gitee From cfa6e04ad429d9cae3748bfe2e6f756ba26ded97 Mon Sep 17 00:00:00 2001 From: Alexey Fofanov Date: Wed, 18 Oct 2023 14:23:22 +0300 Subject: [PATCH 10/10] apps/list.c: Check the result of inserting a provider into provider's stack Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/22492) Signed-off-by: fly2x --- apps/list.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/list.c b/apps/list.c index 514abacfc8..b9439c9e54 100644 --- a/apps/list.c +++ b/apps/list.c @@ -1209,9 +1209,11 @@ static int provider_cmp(const OSSL_PROVIDER * const *a, static int collect_providers(OSSL_PROVIDER *provider, void *stack) { STACK_OF(OSSL_PROVIDER) *provider_stack = stack; - - sk_OSSL_PROVIDER_push(provider_stack, provider); - return 1; + /* + * If OK - result is the index of inserted data + * Error - result is -1 or 0 + */ + return sk_OSSL_PROVIDER_push(provider_stack, provider) > 0 ? 1 : 0; } static void list_provider_info(void) @@ -1226,8 +1228,13 @@ static void list_provider_info(void) BIO_printf(bio_err, "ERROR: Memory allocation\n"); return; } + + if (OSSL_PROVIDER_do_all(NULL, &collect_providers, providers) != 1) { + BIO_printf(bio_err, "ERROR: Memory allocation\n"); + return; + } + BIO_printf(bio_out, "Providers:\n"); - OSSL_PROVIDER_do_all(NULL, &collect_providers, providers); sk_OSSL_PROVIDER_sort(providers); for (i = 0; i < sk_OSSL_PROVIDER_num(providers); i++) { const OSSL_PROVIDER *prov = sk_OSSL_PROVIDER_value(providers, i); -- Gitee