Skip to content

Commit 4e4b18c

Browse files
committed
gh-162141: Use const STACK_OF(SSL_CIPHER)* for SSL_get_ciphers
const-correct two local variables: they are only read via sk_SSL_CIPHER_num() and sk_SSL_CIPHER_value(), which take a const stack, so this is a no-op for existing builds. Also matches BoringSSL's planned change to return const STACK_OF(SSL_CIPHER)* from SSL_get_ciphers() and SSL_CTX_get_ciphers() (https://crbug.com/550501994).
1 parent 910a92b commit 4e4b18c

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎Modules/_ssl.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,9 @@ static PyObject *
22972297
_ssl__SSLSocket_shared_ciphers_impl(PySSLSocket *self)
22982298
/*[clinic end generated code: output=3d174ead2e42c4fd input=869645271e3bc6d0]*/
22992299
{
2300-
STACK_OF(SSL_CIPHER) *server_ciphers;
2300+
const STACK_OF(SSL_CIPHER) *server_ciphers;
2301+
// Should be made const, but OpenSSL's sk_SSL_CIPHER_find() still takes a
2302+
// non-const stack. See https://github.com/openssl/openssl/issues/33707.
23012303
STACK_OF(SSL_CIPHER) *client_ciphers;
23022304
int i, len;
23032305
PyObject *res;
@@ -3953,7 +3955,7 @@ _ssl__SSLContext_get_ciphers_impl(PySSLContext *self)
39533955
/*[clinic end generated code: output=a56e4d68a406dfc4 input=d7fff51631a260ae]*/
39543956
{
39553957
SSL *ssl = NULL;
3956-
STACK_OF(SSL_CIPHER) *sk = NULL;
3958+
const STACK_OF(SSL_CIPHER) *sk = NULL;
39573959
const SSL_CIPHER *cipher;
39583960
int i=0;
39593961
PyObject *result = NULL, *dct;

0 commit comments

Comments
 (0)