File autofs-5.0.6-fix-paged-query-more-results-check.patch of Package autofs.import5769

commit 95ac4259a12f549913c965d2d914ce7d1ec9e325
Author: Ian Kent <raven@themaw.net>
Date:   Thu Dec 1 14:52:48 2011 +0800

    autofs-5.0.6 - fix paged query more results check
    
    When getting paged results from an LDAP server the server returns an
    opaque cookie (of type berval) that is used to retrieve the next page.
    The criteria for deciding if there are more pages is that the berval
    value is non-null and has a non-zero length.
    
    To determine if the berval value has non-zero length autofs checks the
    strlen() of the value but on ppc64 and s390x this can return 0 even if
    the value has non-zero length causing a premature termination of the
    query.
    
    Fix this by also checking the berval length field.
    Also make sure we free the opaque cookie when the query is finished.

Index: autofs-5.0.5/modules/lookup_ldap.c
===================================================================
--- autofs-5.0.5.orig/modules/lookup_ldap.c
+++ autofs-5.0.5/modules/lookup_ldap.c
@@ -2020,7 +2020,8 @@ do_paged:
 	rv = ldap_parse_page_control(sp->ldap,
 				     returnedControls, &sp->totalCount,
 				     &sp->cookie);
-	if (sp->cookie && sp->cookie->bv_val && strlen(sp->cookie->bv_val))
+	if (sp->cookie && sp->cookie->bv_val &&
+	    (strlen(sp->cookie->bv_val) || sp->cookie->bv_len))
 		sp->morePages = TRUE;
 	else
 		sp->morePages = FALSE;
@@ -2361,6 +2362,10 @@ static int read_one_map(struct autofs_po
 		    rv == LDAP_SIZELIMIT_EXCEEDED) {
 			if (sp.result)
 				ldap_msgfree(sp.result);
+			if (sp.cookie) {
+				ber_bvfree(sp.cookie);
+				sp.cookie = NULL;
+			}
 			sp.pageSize = sp.pageSize / 2;
 			if (sp.pageSize < 5) {
 				debug(ap->logopt, MODPREFIX
@@ -2376,6 +2381,8 @@ static int read_one_map(struct autofs_po
 		if (rv != LDAP_SUCCESS || !sp.result) {
 			unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
 			*result_ldap = rv;
+			if (sp.cookie)
+				ber_bvfree(sp.cookie);
 			free(sp.query);
 			return NSS_STATUS_UNAVAIL;
 		}
@@ -2385,6 +2392,8 @@ static int read_one_map(struct autofs_po
 			ldap_msgfree(sp.result);
 			unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
 			*result_ldap = rv;
+			if (sp.cookie)
+				ber_bvfree(sp.cookie);
 			free(sp.query);
 			return NSS_STATUS_NOTFOUND;
 		}
@@ -2396,6 +2405,8 @@ static int read_one_map(struct autofs_po
 	unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
 
 	source->age = age;
+	if (sp.cookie)
+		ber_bvfree(sp.cookie);
 	free(sp.query);
 
 	return NSS_STATUS_SUCCESS;
Index: autofs-5.0.5/CHANGELOG
===================================================================
--- autofs-5.0.5.orig/CHANGELOG
+++ autofs-5.0.5/CHANGELOG
@@ -80,6 +80,7 @@
 - fix ipv6 name for lookup.
 - fix libtirpc ipv6 check.
 - fix ipv6 name for lookup fix.
+- fix paged query more results check.
 
 03/09/2009 autofs-5.0.5
 -----------------------
openSUSE Build Service is sponsored by