Skip to content

Minor code cleanups in ext/openssl #10704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions ext/openssl/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1727,9 +1727,6 @@ PHP_FUNCTION(openssl_spki_export)
if (spkstr_cleaned != NULL) {
efree(spkstr_cleaned);
}
if (s != NULL) {
efree(s);
}
}
/* }}} */

Expand Down
16 changes: 8 additions & 8 deletions ext/openssl/xp_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) /* {{{ */
Copy link
Member

@devnexen devnexen Feb 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: while at it, it might be worth adding then a return check where it s called.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added, thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the missing check would be nice to fix in stable versions... I'll make a PR just cherry-picking that fix.

{
zval *zdhpath = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream), "ssl", "dh_param");
if (zdhpath == NULL) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) /* {{{ */
{
Expand Down