@@ -3614,20 +3614,30 @@ PyDoc_STRVAR(PySSLContext_security_level_doc, "The current security level");
3614
3614
static PyObject *
3615
3615
get_options (PySSLContext * self , void * c )
3616
3616
{
3617
- return PyLong_FromLong (SSL_CTX_get_options (self -> ctx ));
3617
+ return PyLong_FromUnsignedLongLong (SSL_CTX_get_options (self -> ctx ));
3618
3618
}
3619
3619
3620
3620
static int
3621
3621
set_options (PySSLContext * self , PyObject * arg , void * c )
3622
3622
{
3623
- long new_opts , opts , set , clear ;
3624
- long opt_no = (
3623
+ PyObject * new_opts_obj ;
3624
+ unsigned long new_opts_arg ;
3625
+ uint64_t new_opts , opts , clear , set ;
3626
+ uint64_t opt_no = (
3625
3627
SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_TLSv1 |
3626
3628
SSL_OP_NO_TLSv1_1 | SSL_OP_NO_TLSv1_2 | SSL_OP_NO_TLSv1_3
3627
3629
);
3628
3630
3629
- if (!PyArg_Parse (arg , "l " , & new_opts ))
3631
+ if (!PyArg_Parse (arg , "O! " , & PyLong_Type , & new_opts_obj )) {
3630
3632
return -1 ;
3633
+ }
3634
+ new_opts_arg = PyLong_AsUnsignedLong (new_opts_obj );
3635
+ if (new_opts_arg == (unsigned long )-1 && PyErr_Occurred ()) {
3636
+ return -1 ;
3637
+ }
3638
+ Py_BUILD_ASSERT (sizeof (new_opts ) >= sizeof (new_opts_arg ));
3639
+ new_opts = (uint64_t )new_opts_arg ;
3640
+
3631
3641
opts = SSL_CTX_get_options (self -> ctx );
3632
3642
clear = opts & ~new_opts ;
3633
3643
set = ~opts & new_opts ;
@@ -3641,8 +3651,9 @@ set_options(PySSLContext *self, PyObject *arg, void *c)
3641
3651
if (clear ) {
3642
3652
SSL_CTX_clear_options (self -> ctx , clear );
3643
3653
}
3644
- if (set )
3654
+ if (set ) {
3645
3655
SSL_CTX_set_options (self -> ctx , set );
3656
+ }
3646
3657
return 0 ;
3647
3658
}
3648
3659
0 commit comments