From 4e4b18c17434a91fc97dc45b26469598395c3c4c Mon Sep 17 00:00:00 2001 From: Lily Chen Date: Mon, 16 Nov 2026 19:54:46 +0000 Subject: [PATCH] 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). --- Modules/_ssl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 2e4c67b4058bc3..050d22f7915b11 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -2297,7 +2297,9 @@ static PyObject * _ssl__SSLSocket_shared_ciphers_impl(PySSLSocket *self) /*[clinic end generated code: output=3d174ead2e42c4fd input=869645271e3bc6d0]*/ { - STACK_OF(SSL_CIPHER) *server_ciphers; + const STACK_OF(SSL_CIPHER) *server_ciphers; + // Should be made const, but OpenSSL's sk_SSL_CIPHER_find() still takes a + // non-const stack. See https://github.com/openssl/openssl/issues/33707. STACK_OF(SSL_CIPHER) *client_ciphers; int i, len; PyObject *res; @@ -3953,7 +3955,7 @@ _ssl__SSLContext_get_ciphers_impl(PySSLContext *self) /*[clinic end generated code: output=a56e4d68a406dfc4 input=d7fff51631a260ae]*/ { SSL *ssl = NULL; - STACK_OF(SSL_CIPHER) *sk = NULL; + const STACK_OF(SSL_CIPHER) *sk = NULL; const SSL_CIPHER *cipher; int i=0; PyObject *result = NULL, *dct;