43 lines
1.4 KiB
Diff
43 lines
1.4 KiB
Diff
From d2d0d010570160b3daddd754d22f80bf5e435b6f Mon Sep 17 00:00:00 2001
|
|
From: root <root@localhost.localdomain>
|
|
Date: Thu, 5 May 2022 10:38:57 +0800
|
|
Subject: [PATCH] fix a system error and optimize the checking of LDAP results
|
|
|
|
---
|
|
Modules/constants.c | 10 +++++++---
|
|
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/Modules/constants.c b/Modules/constants.c
|
|
index 8b902e0..07d6065 100644
|
|
--- a/Modules/constants.c
|
|
+++ b/Modules/constants.c
|
|
@@ -31,7 +31,8 @@ static PyObject *errobjects[LDAP_ERROR_MAX - LDAP_ERROR_MIN + 1];
|
|
PyObject *
|
|
LDAPerr(int errnum)
|
|
{
|
|
- if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX) {
|
|
+ if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX &&
|
|
+ errobjects[errnum + LDAP_ERROR_OFFSET] != NULL) {
|
|
PyErr_SetNone(errobjects[errnum + LDAP_ERROR_OFFSET]);
|
|
}
|
|
else {
|
|
@@ -88,10 +89,13 @@ LDAPraise_for_message(LDAP *l, LDAPMessage *m)
|
|
ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error);
|
|
}
|
|
|
|
- if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX)
|
|
+ if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX &&
|
|
+ errobjects[errnum + LDAP_ERROR_OFFSET] != NULL) {
|
|
errobj = errobjects[errnum + LDAP_ERROR_OFFSET];
|
|
- else
|
|
+ }
|
|
+ else {
|
|
errobj = LDAPexception_class;
|
|
+ }
|
|
|
|
info = PyDict_New();
|
|
if (info == NULL) {
|
|
--
|
|
2.23.0
|
|
|