From 78f8aabe44da43d03ecf82d8d81f4251cd4bfe4a Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Thu, 10 Mar 2016 16:33:58 -0500 Subject: [PATCH] ssl->ctx cannot be NULL. Most code already dereferences it directly. Change-Id: I227fa91ecbf25a19077f7cfba21b0abd2bc2bd1d Reviewed-on: https://boringssl-review.googlesource.com/7422 Reviewed-by: David Benjamin --- ssl/d1_srtp.c | 2 +- ssl/s3_lib.c | 8 +++----- ssl/ssl_lib.c | 10 ++++------ ssl/t1_lib.c | 14 ++++++-------- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/ssl/d1_srtp.c b/ssl/d1_srtp.c index 0f2b7632..ce15ee21 100644 --- a/ssl/d1_srtp.c +++ b/ssl/d1_srtp.c @@ -211,7 +211,7 @@ STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl) { return ssl->srtp_profiles; } - if (ssl->ctx != NULL && ssl->ctx->srtp_profiles != NULL) { + if (ssl->ctx->srtp_profiles != NULL) { return ssl->ctx->srtp_profiles; } diff --git a/ssl/s3_lib.c b/ssl/s3_lib.c index 119990e7..620e1ca9 100644 --- a/ssl/s3_lib.c +++ b/ssl/s3_lib.c @@ -447,17 +447,15 @@ struct ssl_cipher_preference_list_st *ssl_get_cipher_preferences(SSL *ssl) { return ssl->cipher_list; } - if (ssl->version >= TLS1_1_VERSION && ssl->ctx != NULL && - ssl->ctx->cipher_list_tls11 != NULL) { + if (ssl->version >= TLS1_1_VERSION && ssl->ctx->cipher_list_tls11 != NULL) { return ssl->ctx->cipher_list_tls11; } - if (ssl->version >= TLS1_VERSION && ssl->ctx != NULL && - ssl->ctx->cipher_list_tls10 != NULL) { + if (ssl->version >= TLS1_VERSION && ssl->ctx->cipher_list_tls10 != NULL) { return ssl->ctx->cipher_list_tls10; } - if (ssl->ctx != NULL && ssl->ctx->cipher_list != NULL) { + if (ssl->ctx->cipher_list != NULL) { return ssl->ctx->cipher_list; } diff --git a/ssl/ssl_lib.c b/ssl/ssl_lib.c index 174e9ae3..826b3006 100644 --- a/ssl/ssl_lib.c +++ b/ssl/ssl_lib.c @@ -1259,17 +1259,15 @@ STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *ssl) { return ssl->cipher_list->ciphers; } - if (ssl->version >= TLS1_1_VERSION && ssl->ctx != NULL && - ssl->ctx->cipher_list_tls11 != NULL) { + if (ssl->version >= TLS1_1_VERSION && ssl->ctx->cipher_list_tls11 != NULL) { return ssl->ctx->cipher_list_tls11->ciphers; } - if (ssl->version >= TLS1_VERSION && ssl->ctx != NULL && - ssl->ctx->cipher_list_tls10 != NULL) { + if (ssl->version >= TLS1_VERSION && ssl->ctx->cipher_list_tls10 != NULL) { return ssl->ctx->cipher_list_tls10->ciphers; } - if (ssl->ctx != NULL && ssl->ctx->cipher_list != NULL) { + if (ssl->ctx->cipher_list != NULL) { return ssl->ctx->cipher_list->ciphers; } @@ -1287,7 +1285,7 @@ STACK_OF(SSL_CIPHER) *ssl_get_ciphers_by_id(SSL *ssl) { return ssl->cipher_list_by_id; } - if (ssl->ctx != NULL && ssl->ctx->cipher_list_by_id != NULL) { + if (ssl->ctx->cipher_list_by_id != NULL) { return ssl->ctx->cipher_list_by_id; } diff --git a/ssl/t1_lib.c b/ssl/t1_lib.c index 2c9a0b2a..8facdd38 100644 --- a/ssl/t1_lib.c +++ b/ssl/t1_lib.c @@ -2367,11 +2367,10 @@ static int ssl_check_clienthello_tlsext(SSL *ssl) { int ret = SSL_TLSEXT_ERR_NOACK; int al = SSL_AD_UNRECOGNIZED_NAME; - if (ssl->ctx != NULL && ssl->ctx->tlsext_servername_callback != 0) { + if (ssl->ctx->tlsext_servername_callback != 0) { ret = ssl->ctx->tlsext_servername_callback(ssl, &al, - ssl->ctx->tlsext_servername_arg); - } else if (ssl->initial_ctx != NULL && - ssl->initial_ctx->tlsext_servername_callback != 0) { + ssl->ctx->tlsext_servername_arg); + } else if (ssl->initial_ctx->tlsext_servername_callback != 0) { ret = ssl->initial_ctx->tlsext_servername_callback( ssl, &al, ssl->initial_ctx->tlsext_servername_arg); } @@ -2398,11 +2397,10 @@ static int ssl_check_serverhello_tlsext(SSL *ssl) { int ret = SSL_TLSEXT_ERR_OK; int al = SSL_AD_UNRECOGNIZED_NAME; - if (ssl->ctx != NULL && ssl->ctx->tlsext_servername_callback != 0) { + if (ssl->ctx->tlsext_servername_callback != 0) { ret = ssl->ctx->tlsext_servername_callback(ssl, &al, - ssl->ctx->tlsext_servername_arg); - } else if (ssl->initial_ctx != NULL && - ssl->initial_ctx->tlsext_servername_callback != 0) { + ssl->ctx->tlsext_servername_arg); + } else if (ssl->initial_ctx->tlsext_servername_callback != 0) { ret = ssl->initial_ctx->tlsext_servername_callback( ssl, &al, ssl->initial_ctx->tlsext_servername_arg); }