Assert that alpn_selected is NULL before we assign it
The alpn_selected value in the session should be NULL before we first populate it if this is a new session. We assert to make sure it is. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5715)
This commit is contained in:
parent
53c9818e97
commit
9d5db9c9ab
2 changed files with 20 additions and 2 deletions
|
@ -1679,7 +1679,15 @@ int tls_parse_stoc_alpn(SSL *s, PACKET *pkt, unsigned int context, X509 *x,
|
||||||
s->ext.early_data_ok = 0;
|
s->ext.early_data_ok = 0;
|
||||||
}
|
}
|
||||||
if (!s->hit) {
|
if (!s->hit) {
|
||||||
/* If a new session then update it with the selected ALPN */
|
/*
|
||||||
|
* This is a new session and so alpn_selected should have been
|
||||||
|
* initialised to NULL. We should update it with the selected ALPN.
|
||||||
|
*/
|
||||||
|
if (!ossl_assert(s->session->ext.alpn_selected == NULL)) {
|
||||||
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR, SSL_F_TLS_PARSE_STOC_ALPN,
|
||||||
|
ERR_R_INTERNAL_ERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
s->session->ext.alpn_selected =
|
s->session->ext.alpn_selected =
|
||||||
OPENSSL_memdup(s->s3->alpn_selected, s->s3->alpn_selected_len);
|
OPENSSL_memdup(s->s3->alpn_selected, s->s3->alpn_selected_len);
|
||||||
if (s->session->ext.alpn_selected == NULL) {
|
if (s->session->ext.alpn_selected == NULL) {
|
||||||
|
|
|
@ -2100,7 +2100,17 @@ int tls_handle_alpn(SSL *s)
|
||||||
s->ext.early_data_ok = 0;
|
s->ext.early_data_ok = 0;
|
||||||
|
|
||||||
if (!s->hit) {
|
if (!s->hit) {
|
||||||
/* If a new session update it with the new ALPN value */
|
/*
|
||||||
|
* This is a new session and so alpn_selected should have
|
||||||
|
* been initialised to NULL. We should update it with the
|
||||||
|
* selected ALPN.
|
||||||
|
*/
|
||||||
|
if (!ossl_assert(s->session->ext.alpn_selected == NULL)) {
|
||||||
|
SSLfatal(s, SSL_AD_INTERNAL_ERROR,
|
||||||
|
SSL_F_TLS_HANDLE_ALPN,
|
||||||
|
ERR_R_INTERNAL_ERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
s->session->ext.alpn_selected = OPENSSL_memdup(selected,
|
s->session->ext.alpn_selected = OPENSSL_memdup(selected,
|
||||||
selected_len);
|
selected_len);
|
||||||
if (s->session->ext.alpn_selected == NULL) {
|
if (s->session->ext.alpn_selected == NULL) {
|
||||||
|
|
Loading…
Reference in a new issue