Segfault in LDAPerror() when errnum is out of bounds

Sean Burford unix.gurus at gmail.com
Fri Mar 20 20:14:11 CET 2009


Hi,

When LDAPError receives an errnum from ldap_get_option(l,
LDAP_OPT_ERROR_NUMBER, &errnum) that is out of bounds it causes a segfault.
I have attached a script that triggers it and patch that fixes it.

The test script requires an ldap URI and a BaseDN on the command line.  The
ldap server can be OpenLDAP 2.3 or 2.4 and the BaseDN should be configured
with a syncprov overlay and have syncprov-reloadhint TRUE.  eg:
/tmp/ldap-segfault.py ldap://ldap.example.com dc=example,dc=com

After patching _ldap.so we get a valid Exception:
Traceback (most recent call last):
  File "/tmp/ldap-segfault.py", line 39, in ?
    rtype, rdata, rmsgid, serverctrls = conn.result3(all=1, timeout=60)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 438, in
result3
    rtype, rdata, rmsgid, serverctrls =
self._ldap_call(self._l.result3,msgid,all,timeout)
  File "/usr/lib/python2.4/site-packages/ldap/ldapobject.py", line 97, in
_ldap_call
    result = func(*args,**kwargs)
ldap.LDAPError: {'info': 'sync cookie is stale', 'desc': 'Content Sync
Refresh Required'}

-- 
Thanks,
Sean Burford
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20090320/fa415397/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: python-ldap-2.3.1-error.patch
Type: text/x-diff
Size: 969 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20090320/fa415397/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldap-segfault.py
Type: text/x-python
Size: 1197 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20090320/fa415397/attachment.py>


More information about the python-ldap mailing list