autofs/autofs-5.0.6-fix-paged-query-more-results-check.patch
Ian Kent ca38f0b091 * Tue Nov 8 2011 Ian Kent <ikent@redhat.com> - 1:5.0.6-3
- improve mount location error reporting.
- fix paged query more results check.
- fix dumpmaps not reading maps.
- fix result null check in read_one_map().
- Fix LDAP result leaks on error paths.
- code analysis fixes 1.
- fix not bind mounting local filesystem.
- update dir map-type patch for changed patch order.
- fix wait for master source mutex.
- fix submount shutdown race
- fix fix map source check in file lookup.
- add disable move mount configure option.
2011-11-08 13:13:22 +08:00

88 lines
2.7 KiB
Diff

autofs-5.0.6 - fix paged query more results check
From: Ian Kent <raven@themaw.net>
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.
---
CHANGELOG | 1 +
modules/lookup_ldap.c | 13 ++++++++++++-
2 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index a178b74..884a9ae 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,7 @@
=======================
- fix ipv6 name for lookup fix.
- improve mount location error reporting.
+- fix paged query more results check.
28/06/2011 autofs-5.0.6
-----------------------
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
index 719fed1..a25050a 100644
--- a/modules/lookup_ldap.c
+++ b/modules/lookup_ldap.c
@@ -2041,7 +2041,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;
@@ -2382,6 +2383,10 @@ static int read_one_map(struct autofs_point *ap,
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
@@ -2397,6 +2402,8 @@ static int read_one_map(struct autofs_point *ap,
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;
}
@@ -2406,6 +2413,8 @@ static int read_one_map(struct autofs_point *ap,
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;
}
@@ -2417,6 +2426,8 @@ static int read_one_map(struct autofs_point *ap,
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;