Skip to content

Commit 626bc0e

Browse files
committed
Remove php_openssl_cipher_get_version()
This was added in 7.1 when add_assoc_string mistakenly accepted a char* rather than const char* parameter and is no longer needed. We can use SSL_CIPHER_get_version() directly.
1 parent 6191df7 commit 626bc0e

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

ext/openssl/xp_ssl.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -984,21 +984,6 @@ static int php_openssl_set_local_cert(SSL_CTX *ctx, php_stream *stream) /* {{{ *
984984
}
985985
/* }}} */
986986

987-
#define PHP_SSL_MAX_VERSION_LEN 32
988-
989-
static char *php_openssl_cipher_get_version(const SSL_CIPHER *c, char *buffer, size_t max_len) /* {{{ */
990-
{
991-
const char *version = SSL_CIPHER_get_version(c);
992-
993-
strncpy(buffer, version, max_len);
994-
if (max_len <= strlen(version)) {
995-
buffer[max_len - 1] = 0;
996-
}
997-
998-
return buffer;
999-
}
1000-
/* }}} */
1001-
1002987
#if PHP_OPENSSL_API_VERSION < 0x10100
1003988
static int php_openssl_get_crypto_method_ctx_flags(int method_flags) /* {{{ */
1004989
{
@@ -1843,7 +1828,6 @@ static zend_array *php_openssl_capture_session_meta(SSL *ssl_handle) /* {{{ */
18431828
char *proto_str;
18441829
long proto = SSL_version(ssl_handle);
18451830
const SSL_CIPHER *cipher = SSL_get_current_cipher(ssl_handle);
1846-
char version_str[PHP_SSL_MAX_VERSION_LEN];
18471831

18481832
switch (proto) {
18491833
#ifdef HAVE_TLS13
@@ -1876,8 +1860,7 @@ static zend_array *php_openssl_capture_session_meta(SSL *ssl_handle) /* {{{ */
18761860
add_assoc_string(&meta_arr, "protocol", proto_str);
18771861
add_assoc_string(&meta_arr, "cipher_name", (char *) SSL_CIPHER_get_name(cipher));
18781862
add_assoc_long(&meta_arr, "cipher_bits", SSL_CIPHER_get_bits(cipher, NULL));
1879-
add_assoc_string(&meta_arr, "cipher_version",
1880-
php_openssl_cipher_get_version(cipher, version_str, PHP_SSL_MAX_VERSION_LEN));
1863+
add_assoc_string(&meta_arr, "cipher_version", SSL_CIPHER_get_version(cipher));
18811864

18821865
return Z_ARR(meta_arr);
18831866
}
@@ -2450,7 +2433,6 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
24502433
if (sslsock->ssl_active) {
24512434
zval tmp;
24522435
char *proto_str;
2453-
char version_str[PHP_SSL_MAX_VERSION_LEN];
24542436
const SSL_CIPHER *cipher;
24552437

24562438
array_init(&tmp);
@@ -2477,8 +2459,7 @@ static int php_openssl_sockop_set_option(php_stream *stream, int option, int val
24772459
add_assoc_string(&tmp, "protocol", proto_str);
24782460
add_assoc_string(&tmp, "cipher_name", (char *) SSL_CIPHER_get_name(cipher));
24792461
add_assoc_long(&tmp, "cipher_bits", SSL_CIPHER_get_bits(cipher, NULL));
2480-
add_assoc_string(&tmp, "cipher_version",
2481-
php_openssl_cipher_get_version(cipher, version_str, PHP_SSL_MAX_VERSION_LEN));
2462+
add_assoc_string(&tmp, "cipher_version", SSL_CIPHER_get_version(cipher));
24822463

24832464
#ifdef HAVE_TLS_ALPN
24842465
{

0 commit comments

Comments
 (0)