Skip to content

Commit 35a3ae0

Browse files
committed
gh-136306: Address additional review comments
1 parent e0fdd25 commit 35a3ae0

2 files changed

Lines changed: 3 additions & 10 deletions

File tree

Lib/test/test_ssl.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -964,22 +964,15 @@ def test_get_ciphers(self):
964964

965965
def test_set_groups(self):
966966
ctx = ssl.create_default_context()
967-
968-
# Test valid group list
969967
self.assertIsNone(ctx.set_groups('P-256:X25519'))
970-
971-
# Test invalid group list
972968
self.assertRaises(ssl.SSLError, ctx.set_groups, 'P-256:xxx')
973969

974970
@unittest.skipUnless(CAN_GET_AVAILABLE_OPENSSL_GROUPS,
975971
"OpenSSL version doesn't support getting groups")
976972
def test_get_groups(self):
977973
ctx = ssl.create_default_context()
978-
979-
# P-256 isn't an IANA name, so it shouldn't be returned by default
974+
# By default, only return official IANA names.
980975
self.assertNotIn('P-256', ctx.get_groups())
981-
982-
# Aliases like P-256 sbould be returned when include_aliases is set
983976
self.assertIn('P-256', ctx.get_groups(include_aliases=True))
984977

985978
def test_options(self):

Modules/_ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,7 @@ _ssl__SSLContext_get_groups_impl(PySSLContext *self, int include_aliases)
34623462
#if OPENSSL_VERSION_NUMBER >= 0x30500000L
34633463
STACK_OF(OPENSSL_CSTRING) *groups = NULL;
34643464
const char *group;
3465-
size_t i, num;
3465+
int i, num;
34663466
PyObject *item, *result = NULL;
34673467

34683468
// This "groups" object is dynamically allocated, but the strings inside
@@ -3492,7 +3492,7 @@ _ssl__SSLContext_get_groups_impl(PySSLContext *self, int include_aliases)
34923492
// Group names are plain ASCII, so there's no chance of a decoding
34933493
// error here. However, an allocation failure could occur when
34943494
// constructing the Unicode version of the names.
3495-
item = PyUnicode_DecodeFSDefault(group);
3495+
item = PyUnicode_DecodeASCII(group, strlen(group), "strict");
34963496
if (item == NULL) {
34973497
_setSSLError(get_state_ctx(self), "Can't allocate group name", 0, __FILE__, __LINE__);
34983498
goto error;

0 commit comments

Comments
 (0)