fix a system error and optimize the checking of LDAP results

(cherry picked from commit 57c34a80df7b416fb53192f9d2b0ec8ae2066413)
This commit is contained in:
xingxing 2022-05-06 11:34:50 +08:00 committed by openeuler-sync-bot
parent faa1aa4942
commit e8551f02b3
2 changed files with 54 additions and 4 deletions

View File

@ -0,0 +1,42 @@
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

View File

@ -1,11 +1,13 @@
Name: python-ldap
Version: 3.3.1
Release: 2
Release: 3
Summary: An object-oriented API to access LDAP directory servers
License: Python
License: Python-2.0
URL: http://python-ldap.org/
Source0: https://files.pythonhosted.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz
Patch0: Handle-unknown-LDAP-result-code.patch
BuildRequires: gcc openldap-devel openssl-devel cyrus-sasl-devel
BuildRequires: python3-devel python3-setuptools openldap-servers
@ -34,7 +36,7 @@ OpenLDAP 2.x libraries, and contains modules for other LDAP-related tasks\
%package_help
%prep
%autosetup -n %{name}-%{version}
%autosetup -p1 -n %{name}-%{version}
find . -name '*.py' | xargs sed -i '1s|^#!/usr/bin/env python|#!%{__python3}|'
sed -i 's,-Werror,-Wignore,g' tox.ini
%build
@ -55,6 +57,12 @@ sed -i 's,-Werror,-Wignore,g' tox.ini
%doc CHANGES README TODO Demo
%changelog
* Fri May 06 2022 xingxing <xingxing9@h-partners.com> - 3.3.1-3
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:fix a system error and optimize the checking of LDAP results
* Mon Sep 06 2021 gaihuiying <gaihuiying1@huawei.com> - 3.3.1-2
- Type:requirements
- Id:NA
@ -62,7 +70,7 @@ sed -i 's,-Werror,-Wignore,g' tox.ini
- DESC:modify to generate debug rpms
* Tue Feb 02 2021 xihaochen <xihaochen@huawei.com> - 3.3.1-1
- Type:requirements
- Type:requirements
- Id:NA
- SUG:NA
- DESC:update python-ldap to 3.3.1