Skip to content

Commit 472cc9f

Browse files
authored
[3.6] _ssl_: Fix compiler warning (GH-3559) (#3569)
Cast Py_buffer.len (Py_ssize_t, signed) to size_t (unsigned) to prevent the following warning: Modules/_ssl.c:3089:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]. (cherry picked from commit 5a61559)
1 parent 5dbb28e commit 472cc9f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Modules/_ssl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,6 +3024,12 @@ _ssl__SSLContext__set_alpn_protocols_impl(PySSLContext *self,
30243024
/*[clinic end generated code: output=87599a7f76651a9b input=9bba964595d519be]*/
30253025
{
30263026
#ifdef HAVE_ALPN
3027+
if ((size_t)protos->len > UINT_MAX) {
3028+
PyErr_Format(PyExc_OverflowError,
3029+
"protocols longer than %d bytes", UINT_MAX);
3030+
return NULL;
3031+
}
3032+
30273033
PyMem_FREE(self->alpn_protocols);
30283034
self->alpn_protocols = PyMem_Malloc(protos->len);
30293035
if (!self->alpn_protocols)

0 commit comments

Comments
 (0)