From 1d19ab7e66bd6abff2fa07260542989d0ce2bf9a Mon Sep 17 00:00:00 2001 From: Shubham Mittal Date: Mon, 11 Mar 2024 20:28:32 -0700 Subject: [PATCH] changed null check convention and fixed comments --- include/openssl/ssl.h | 1 - ssl/ssl_cipher.cc | 2 +- ssl/ssl_lib.cc | 4 ++-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/include/openssl/ssl.h b/include/openssl/ssl.h index e0245395d5..607d75d54c 100644 --- a/include/openssl/ssl.h +++ b/include/openssl/ssl.h @@ -1847,7 +1847,6 @@ OPENSSL_EXPORT STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *ssl); // SSL_client_hello_get0_ciphers provides access to the client ciphers field from the // Client Hello, optionally writing the result to an out pointer. It returns the field // length if successful, or 0 if |ssl| is a client or the handshake hasn't occurred yet. -// Free |*out| after use if provided to the function. OPENSSL_EXPORT size_t SSL_client_hello_get0_ciphers(SSL *ssl, const unsigned char **out); // SSL_session_reused returns one if |ssl| performed an abbreviated handshake diff --git a/ssl/ssl_cipher.cc b/ssl/ssl_cipher.cc index 0cfcbe76cc..58b18e8091 100644 --- a/ssl/ssl_cipher.cc +++ b/ssl/ssl_cipher.cc @@ -1447,7 +1447,7 @@ const SSL_CIPHER *SSL_get_cipher_by_value(uint16_t value) { } const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr) { - if (ptr) { + if (ptr != nullptr) { // Taking first element and left shit by 8 bits to set upper 8 bits. // Bitwise OR with second element to set lower 8 bits of 16 bit integer. uint16_t cipher_id = static_cast((ptr[0] << 8) | ptr[1]);; diff --git a/ssl/ssl_lib.cc b/ssl/ssl_lib.cc index 3993c8ee14..d0a858a0d4 100644 --- a/ssl/ssl_lib.cc +++ b/ssl/ssl_lib.cc @@ -3318,11 +3318,11 @@ int SSL_set1_curves_list(SSL *ssl, const char *curves) { size_t SSL_client_hello_get0_ciphers(SSL *ssl, const unsigned char **out) { STACK_OF(SSL_CIPHER) *client_cipher_suites = SSL_get_client_ciphers(ssl); - if (!client_cipher_suites) { + if (client_cipher_suites == nullptr) { return 0; } - if (out) { + if (out != nullptr) { // Called before if(!ssl->client_cipher_suites_arr.empty()) { *out = reinterpret_cast(ssl->client_cipher_suites_arr.data());