quic_tls_secrets_keys_free() calls EVP_CIPHER_CTX_free() on <hp_ctx> without
checking it against EVP_CIPHER_CTX_CHACHA20. With AWS-LC this member may hold
this value, which points to a static object and not to an allocated context.
quic_tls_ctx_secs_free() already guards against it.
This cannot happen today, as the only caller runs before the contexts are
created. Add the same guard, and reset <hp_ctx> and <ctx> so that calling this
function twice is harmless.
Should be backported as far as 2.6 to ease any future bug fix backport.
}
/* HP protection */
+#ifdef QUIC_AEAD_API
+ if (secs->hp_ctx != EVP_CIPHER_CTX_CHACHA20)
+ EVP_CIPHER_CTX_free(secs->hp_ctx);
+#else
EVP_CIPHER_CTX_free(secs->hp_ctx);
+#endif
+ secs->hp_ctx = NULL;
/* AEAD decryption */
QUIC_AEAD_CTX_free(secs->ctx);
+ secs->ctx = NULL;
pool_free(pool_head_quic_tls_iv, secs->iv);
pool_free(pool_head_quic_tls_key, secs->key);