Fix DH error-handling in tls_process_key_exchange.
The set0 setters take ownership of their arguments, so the values should be set to NULL to avoid a double-free in the cleanup block should ssl_security(SSL_SECOP_TMP_DH) fail. Found by BoringSSL's WeakDH test. Reviewed-by: Kurt Roeckx <kurt@openssl.org> Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/1299)
This commit is contained in:
parent
3307000d98
commit
e99ab8ffd7
1 changed files with 2 additions and 0 deletions
|
@ -1461,12 +1461,14 @@ MSG_PROCESS_RETURN tls_process_key_exchange(SSL *s, PACKET *pkt)
|
|||
SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_BN_LIB);
|
||||
goto dherr;
|
||||
}
|
||||
p = g = NULL;
|
||||
|
||||
if (!DH_set0_key(dh, bnpub_key, NULL)) {
|
||||
al = SSL_AD_INTERNAL_ERROR;
|
||||
SSLerr(SSL_F_TLS_PROCESS_KEY_EXCHANGE, ERR_R_BN_LIB);
|
||||
goto dherr;
|
||||
}
|
||||
bnpub_key = NULL;
|
||||
|
||||
if (!ssl_security(s, SSL_SECOP_TMP_DH, DH_security_bits(dh), 0, dh)) {
|
||||
al = SSL_AD_HANDSHAKE_FAILURE;
|
||||
|
|
Loading…
Reference in a new issue