From 3de5794bae0893ba1d3acae2e762709bd6ec333d Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 25 Feb 2023 20:45:44 +0100 Subject: [PATCH 1/2] Remove dead code s is always NULL, so the check is always false. --- ext/openssl/openssl.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index e377b7a92eed2..5738228dbacf6 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -1672,7 +1672,7 @@ PHP_FUNCTION(openssl_spki_verify) PHP_FUNCTION(openssl_spki_export) { size_t spkstr_len; - char *spkstr, * spkstr_cleaned = NULL, * s = NULL; + char *spkstr, * spkstr_cleaned = NULL; int spkstr_cleaned_len; EVP_PKEY *pkey = NULL; @@ -1727,9 +1727,6 @@ PHP_FUNCTION(openssl_spki_export) if (spkstr_cleaned != NULL) { efree(spkstr_cleaned); } - if (s != NULL) { - efree(s); - } } /* }}} */ From 1a0059289c53c648b6d0dc33757eb00118de73c0 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 25 Feb 2023 20:46:07 +0100 Subject: [PATCH 2/2] Use zend_result where appropriate in ext/openssl --- ext/openssl/xp_ssl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c index 2ec25bee09117..c1c7ec7b704d2 100644 --- a/ext/openssl/xp_ssl.c +++ b/ext/openssl/xp_ssl.c @@ -513,7 +513,7 @@ static bool php_openssl_matches_common_name(X509 *peer, const char *subject_name } /* }}} */ -static int php_openssl_apply_peer_verification_policy(SSL *ssl, X509 *peer, php_stream *stream) /* {{{ */ +static zend_result php_openssl_apply_peer_verification_policy(SSL *ssl, X509 *peer, php_stream *stream) /* {{{ */ { zval *val = NULL; zval *peer_fingerprint; @@ -840,7 +840,7 @@ static long php_openssl_load_stream_cafile(X509_STORE *cert_store, const char *c } /* }}} */ -static int php_openssl_enable_peer_verification(SSL_CTX *ctx, php_stream *stream) /* {{{ */ +static zend_result php_openssl_enable_peer_verification(SSL_CTX *ctx, php_stream *stream) /* {{{ */ { zval *val = NULL; char *cafile = NULL; @@ -900,7 +900,7 @@ static void php_openssl_disable_peer_verification(SSL_CTX *ctx, php_stream *stre } /* }}} */ -static int php_openssl_set_local_cert(SSL_CTX *ctx, php_stream *stream) /* {{{ */ +static zend_result php_openssl_set_local_cert(SSL_CTX *ctx, php_stream *stream) /* {{{ */ { zval *val = NULL; char *certfile = NULL; @@ -1204,7 +1204,7 @@ static RSA *php_openssl_tmp_rsa_cb(SSL *s, int is_export, int keylength) } #endif -static int php_openssl_set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /* {{{ */ +static zend_result php_openssl_set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /* {{{ */ { zval *zdhpath = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "ssl", "dh_param"); if (zdhpath == NULL) { @@ -1265,7 +1265,7 @@ static int php_openssl_set_server_dh_param(php_stream * stream, SSL_CTX *ctx) /* /* }}} */ #if defined(HAVE_ECDH) && PHP_OPENSSL_API_VERSION < 0x10100 -static int php_openssl_set_server_ecdh_curve(php_stream *stream, SSL_CTX *ctx) /* {{{ */ +static zend_result php_openssl_set_server_ecdh_curve(php_stream *stream, SSL_CTX *ctx) /* {{{ */ { zval *zvcurve; int curve_nid; @@ -1301,7 +1301,7 @@ static int php_openssl_set_server_ecdh_curve(php_stream *stream, SSL_CTX *ctx) / /* }}} */ #endif -static int php_openssl_set_server_specific_opts(php_stream *stream, SSL_CTX *ctx) /* {{{ */ +static zend_result php_openssl_set_server_specific_opts(php_stream *stream, SSL_CTX *ctx) /* {{{ */ { zval *zv; long ssl_ctx_options = SSL_CTX_get_options(ctx); @@ -1400,7 +1400,7 @@ static SSL_CTX *php_openssl_create_sni_server_ctx(char *cert_path, char *key_pat } /* }}} */ -static int php_openssl_enable_server_sni(php_stream *stream, php_openssl_netstream_data_t *sslsock) /* {{{ */ +static zend_result php_openssl_enable_server_sni(php_stream *stream, php_openssl_netstream_data_t *sslsock) /* {{{ */ { zval *val; zval *current; @@ -1611,7 +1611,7 @@ static int php_openssl_server_alpn_callback(SSL *ssl_handle, #endif -int php_openssl_setup_crypto(php_stream *stream, +zend_result php_openssl_setup_crypto(php_stream *stream, php_openssl_netstream_data_t *sslsock, php_stream_xport_crypto_param *cparam) /* {{{ */ {