Skip to content

Commit d9ded15

Browse files
committed
Handle unknown LDAP result code
Prevent ``SystemError: error return without exception set`` when LDAP server returns an unknown LDAP result code. Fixes: #240 Signed-off-by: Christian Heimes <cheimes@redhat.com>
1 parent 84bbf5e commit d9ded15

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

Modules/constants.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ static PyObject *errobjects[LDAP_ERROR_MAX - LDAP_ERROR_MIN + 1];
3131
PyObject *
3232
LDAPerr(int errnum)
3333
{
34-
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX) {
34+
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX &&
35+
errobjects[errnum + LDAP_ERROR_OFFSET] != NULL) {
3536
PyErr_SetNone(errobjects[errnum + LDAP_ERROR_OFFSET]);
3637
}
3738
else {
@@ -88,10 +89,13 @@ LDAPraise_for_message(LDAP *l, LDAPMessage *m)
8889
ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error);
8990
}
9091

91-
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX)
92+
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX &&
93+
errobjects[errnum + LDAP_ERROR_OFFSET] != NULL) {
9294
errobj = errobjects[errnum + LDAP_ERROR_OFFSET];
93-
else
95+
}
96+
else {
9497
errobj = LDAPexception_class;
98+
}
9599

96100
info = PyDict_New();
97101
if (info == NULL) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy