Added check for SSL_get_current_cipher() results.

The function may return NULL and result need to be checked before use.
This commit is contained in:
Vladimir Homutov 2020-04-04 22:25:41 +03:00
parent 61aa190cfb
commit 757b3e7bcf

View File

@ -62,13 +62,19 @@ static ngx_int_t
ngx_quic_ciphers(ngx_ssl_conn_t *ssl_conn, ngx_quic_ciphers_t *ciphers, ngx_quic_ciphers(ngx_ssl_conn_t *ssl_conn, ngx_quic_ciphers_t *ciphers,
enum ssl_encryption_level_t level) enum ssl_encryption_level_t level)
{ {
ngx_int_t id, len; ngx_int_t id, len;
const SSL_CIPHER *cipher;
if (level == ssl_encryption_initial) { if (level == ssl_encryption_initial) {
id = NGX_AES_128_GCM_SHA256; id = NGX_AES_128_GCM_SHA256;
} else { } else {
id = SSL_CIPHER_get_id(SSL_get_current_cipher(ssl_conn)) & 0xffff; cipher = SSL_get_current_cipher(ssl_conn);
if (cipher == NULL) {
return NGX_ERROR;
}
id = SSL_CIPHER_get_id(cipher) & 0xffff;
} }
switch (id) { switch (id) {