Skip to content

Commit

Permalink
Check valid connection in LDAPObject.set/get_option
Browse files Browse the repository at this point in the history
set_option() and get_option() now verify that LDAPObject is valid. This
fixes an assertion error and possible segfault after unbind_ext().

Signed-off-by: Christian Heimes <cheimes@redhat.com>
  • Loading branch information
Christian Heimes authored and Petr Viktorin committed Jun 5, 2020
1 parent 72a4707 commit 0870889
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Modules/LDAPObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1365,14 +1365,16 @@ l_ldap_start_tls_s(LDAPObject *self, PyObject *args)
/* ldap_set_option */

static PyObject *
l_ldap_set_option(PyObject *self, PyObject *args)
l_ldap_set_option(LDAPObject *self, PyObject *args)
{
PyObject *value;
int option;

if (!PyArg_ParseTuple(args, "iO:set_option", &option, &value))
return NULL;
if (!LDAP_set_option((LDAPObject *)self, option, value))
if (not_valid(self))
return NULL;
if (!LDAP_set_option(self, option, value))
return NULL;
Py_INCREF(Py_None);
return Py_None;
Expand All @@ -1381,13 +1383,15 @@ l_ldap_set_option(PyObject *self, PyObject *args)
/* ldap_get_option */

static PyObject *
l_ldap_get_option(PyObject *self, PyObject *args)
l_ldap_get_option(LDAPObject *self, PyObject *args)
{
int option;

if (!PyArg_ParseTuple(args, "i:get_option", &option))
return NULL;
return LDAP_get_option((LDAPObject *)self, option);
if (not_valid(self))
return NULL;
return LDAP_get_option(self, option);
}

/* ldap_passwd */
Expand Down

0 comments on commit 0870889

Please sign in to comment.