From 3a29494bdaf3b5532dd9aa5780b794430a811560 Mon Sep 17 00:00:00 2001 From: Kurt Zeilenga Date: Sun, 31 Jan 1999 18:57:01 +0000 Subject: [PATCH] import ldap_sort_entries zero entry bug fix from devel. --- CHANGES | 3 ++- libraries/libldap/sort.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 4e28e98117..dc99db5326 100644 --- a/CHANGES +++ b/CHANGES @@ -4,7 +4,8 @@ Changes included in OpenLDAP 1.2 CVS Tag: OPENLDAP_REL_ENG_1_2 Fixed slapd/ldbm/add cache set state deadlock bug Fixed slapd/ldbm/add,modrdn,delete e_ndn handling - Fixed -lldap/ldap_init() + Fixed -lldap/ldap_init() bug + Fixed -lldap/ldap_sort_entries() zero entries bug Updated ldap_open(3) man page to note ldap_init() is preferred. Updated internal thread library Updated slapd/back-shell to use void* private and pid_t diff --git a/libraries/libldap/sort.c b/libraries/libldap/sort.c index 0e2996cac0..9a4427b473 100644 --- a/libraries/libldap/sort.c +++ b/libraries/libldap/sort.c @@ -93,6 +93,18 @@ ldap_sort_entries( count = ldap_count_entries( ld, *chain ); + + if ( count < 0 ) { + if( ld != NULL ) { + ld->ld_errno = LDAP_PARAM_ERROR; + } + return -1; + + } else if ( count < 2 ) { + /* zero or one entries -- already sorted! */ + return 0; + } + if ( (et = (struct entrything *) malloc( count * sizeof(struct entrything) )) == NULL ) { ld->ld_errno = LDAP_NO_MEMORY; -- 2.39.5