|
Ian Kent |
ca38f0 |
autofs-5.0.6 - fix paged query more results check
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
From: Ian Kent <raven@themaw.net>
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
When getting paged results from an LDAP server the server returns an
|
|
Ian Kent |
ca38f0 |
opaque cookie (of type berval) that is used to retrieve the next page.
|
|
Ian Kent |
ca38f0 |
The criteria for deciding if there are more pages is that the berval
|
|
Ian Kent |
ca38f0 |
value is non-null and has a non-zero length.
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
To determine if the berval value has non-zero length autofs checks the
|
|
Ian Kent |
ca38f0 |
strlen() of the value but on ppc64 and s390x this can return 0 even if
|
|
Ian Kent |
ca38f0 |
the value has non-zero length causing a premature termination of the
|
|
Ian Kent |
ca38f0 |
query.
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
Fix this by also checking the berval length field.
|
|
Ian Kent |
ca38f0 |
Also make sure we free the opaque cookie when the query is finished.
|
|
Ian Kent |
ca38f0 |
---
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
CHANGELOG | 1 +
|
|
Ian Kent |
ca38f0 |
modules/lookup_ldap.c | 13 ++++++++++++-
|
|
Ian Kent |
ca38f0 |
2 files changed, 13 insertions(+), 1 deletions(-)
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
diff --git a/CHANGELOG b/CHANGELOG
|
|
Ian Kent |
ca38f0 |
index a178b74..884a9ae 100644
|
|
Ian Kent |
ca38f0 |
--- a/CHANGELOG
|
|
Ian Kent |
ca38f0 |
+++ b/CHANGELOG
|
|
Ian Kent |
ca38f0 |
@@ -2,6 +2,7 @@
|
|
Ian Kent |
ca38f0 |
=======================
|
|
Ian Kent |
ca38f0 |
- fix ipv6 name for lookup fix.
|
|
Ian Kent |
ca38f0 |
- improve mount location error reporting.
|
|
Ian Kent |
ca38f0 |
+- fix paged query more results check.
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
28/06/2011 autofs-5.0.6
|
|
Ian Kent |
ca38f0 |
-----------------------
|
|
Ian Kent |
ca38f0 |
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
|
|
Ian Kent |
ca38f0 |
index 719fed1..a25050a 100644
|
|
Ian Kent |
ca38f0 |
--- a/modules/lookup_ldap.c
|
|
Ian Kent |
ca38f0 |
+++ b/modules/lookup_ldap.c
|
|
Ian Kent |
ca38f0 |
@@ -2041,7 +2041,8 @@ do_paged:
|
|
Ian Kent |
ca38f0 |
rv = ldap_parse_page_control(sp->ldap,
|
|
Ian Kent |
ca38f0 |
returnedControls, &sp->totalCount,
|
|
Ian Kent |
ca38f0 |
&sp->cookie);
|
|
Ian Kent |
ca38f0 |
- if (sp->cookie && sp->cookie->bv_val && strlen(sp->cookie->bv_val))
|
|
Ian Kent |
ca38f0 |
+ if (sp->cookie && sp->cookie->bv_val &&
|
|
Ian Kent |
ca38f0 |
+ (strlen(sp->cookie->bv_val) || sp->cookie->bv_len))
|
|
Ian Kent |
ca38f0 |
sp->morePages = TRUE;
|
|
Ian Kent |
ca38f0 |
else
|
|
Ian Kent |
ca38f0 |
sp->morePages = FALSE;
|
|
Ian Kent |
ca38f0 |
@@ -2382,6 +2383,10 @@ static int read_one_map(struct autofs_point *ap,
|
|
Ian Kent |
ca38f0 |
rv == LDAP_SIZELIMIT_EXCEEDED) {
|
|
Ian Kent |
ca38f0 |
if (sp.result)
|
|
Ian Kent |
ca38f0 |
ldap_msgfree(sp.result);
|
|
Ian Kent |
ca38f0 |
+ if (sp.cookie) {
|
|
Ian Kent |
ca38f0 |
+ ber_bvfree(sp.cookie);
|
|
Ian Kent |
ca38f0 |
+ sp.cookie = NULL;
|
|
Ian Kent |
ca38f0 |
+ }
|
|
Ian Kent |
ca38f0 |
sp.pageSize = sp.pageSize / 2;
|
|
Ian Kent |
ca38f0 |
if (sp.pageSize < 5) {
|
|
Ian Kent |
ca38f0 |
debug(ap->logopt, MODPREFIX
|
|
Ian Kent |
ca38f0 |
@@ -2397,6 +2402,8 @@ static int read_one_map(struct autofs_point *ap,
|
|
Ian Kent |
ca38f0 |
if (rv != LDAP_SUCCESS || !sp.result) {
|
|
Ian Kent |
ca38f0 |
unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
|
|
Ian Kent |
ca38f0 |
*result_ldap = rv;
|
|
Ian Kent |
ca38f0 |
+ if (sp.cookie)
|
|
Ian Kent |
ca38f0 |
+ ber_bvfree(sp.cookie);
|
|
Ian Kent |
ca38f0 |
free(sp.query);
|
|
Ian Kent |
ca38f0 |
return NSS_STATUS_UNAVAIL;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
@@ -2406,6 +2413,8 @@ static int read_one_map(struct autofs_point *ap,
|
|
Ian Kent |
ca38f0 |
ldap_msgfree(sp.result);
|
|
Ian Kent |
ca38f0 |
unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
|
|
Ian Kent |
ca38f0 |
*result_ldap = rv;
|
|
Ian Kent |
ca38f0 |
+ if (sp.cookie)
|
|
Ian Kent |
ca38f0 |
+ ber_bvfree(sp.cookie);
|
|
Ian Kent |
ca38f0 |
free(sp.query);
|
|
Ian Kent |
ca38f0 |
return NSS_STATUS_NOTFOUND;
|
|
Ian Kent |
ca38f0 |
}
|
|
Ian Kent |
ca38f0 |
@@ -2417,6 +2426,8 @@ static int read_one_map(struct autofs_point *ap,
|
|
Ian Kent |
ca38f0 |
unbind_ldap_connection(ap->logopt, sp.ldap, ctxt);
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
source->age = age;
|
|
Ian Kent |
ca38f0 |
+ if (sp.cookie)
|
|
Ian Kent |
ca38f0 |
+ ber_bvfree(sp.cookie);
|
|
Ian Kent |
ca38f0 |
free(sp.query);
|
|
Ian Kent |
ca38f0 |
|
|
Ian Kent |
ca38f0 |
return NSS_STATUS_SUCCESS;
|