Commit ba627dbcde for openssl.org
commit ba627dbcde3037dd93660a676d0b98e40a787720
Author: Jakub Zelenka <jakub.zelenka@openssl.foundation>
Date: Wed Aug 5 15:04:02 2026 +0200
ssl: add missing SSLfatal in PSK premaster secret generation
An allocation failure for the PSK premaster secret buffer in
ssl_generate_master_secret() returned failure without calling
SSLfatal(), while its callers on both the client key exchange
construction and processing paths assume the fatal state was
already set. Also cover the unreachable no-PSK fallback branch.
Assisted-by: Claude:claude-fable-5
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.foundation>
MergeDate: Tue Aug 11 07:28:05 2026
(Merged from https://github.com/openssl/openssl/pull/32195)
diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c
index 1e2b052354..8662471dde 100644
--- a/ssl/s3_lib.c
+++ b/ssl/s3_lib.c
@@ -5307,8 +5307,10 @@ int ssl_generate_master_secret(SSL_CONNECTION *s, unsigned char *pms,
pskpmslen = 4 + pmslen + psklen;
pskpms = OPENSSL_malloc(pskpmslen);
- if (pskpms == NULL)
+ if (pskpms == NULL) {
+ SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_CRYPTO_LIB);
goto err;
+ }
t = pskpms;
s2n(pmslen, t);
if (alg_k & SSL_kPSK)
@@ -5332,6 +5334,7 @@ int ssl_generate_master_secret(SSL_CONNECTION *s, unsigned char *pms,
OPENSSL_clear_free(pskpms, pskpmslen);
#else
/* Should never happen */
+ SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_INTERNAL_ERROR);
goto err;
#endif
} else {