ldap/servers/slapd/ldaputil.c | 23 ++++++-----------------
1 file changed, 6 insertions(+), 17 deletions(-)
New commits:
commit 30cb81261036e1347e2dcb86b801dd89d13a2849
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Tue Feb 8 14:09:58 2011 -0800
Bug 675853 - dirsrv crash segfault in need_new_pw()
A bind DN with a trailing tab in the RDN can cause ns-slapd to crash.
This is ultimately caused by the function that explodes the bind DN
trimming off the tab character, causing the bind entry to be found
by the backend. The frontend uses different logic to find the
bind entry, which fails to find the entry. This discrepency leads
to a crash.
The fix is to only trim trailing spaces (0x20) from RDN values when
exploding a DN. The DN explode function is an internal function
when built against the OpenLDAP client libs, but we use an external
MozLDAP call when built against MozLDAP. This patch makes us always
use our own internal function regardless of the client libs we are
built against.
diff --git a/ldap/servers/slapd/ldaputil.c b/ldap/servers/slapd/ldaputil.c
index 11fe4fb..34aa12e 100644
--- a/ldap/servers/slapd/ldaputil.c
+++ b/ldap/servers/slapd/ldaputil.c
@@ -101,14 +101,12 @@
#include <ldappr.h>
#endif
-#if defined(USE_OPENLDAP)
/* the server depends on the old, deprecated ldap_explode behavior which openldap
- does not support - the use of the mozldap code should be seen as a temporary
- measure which we should remove as we improve our internal DN handling */
+ does not support - the use of the mozldap code should be discouraged as
+ there are issues that mozldap does not handle correctly. */
static char **mozldap_ldap_explode( const char *dn, const int notypes, const int nametype
);
static char **mozldap_ldap_explode_dn( const char *dn, const int notypes );
static char **mozldap_ldap_explode_rdn( const char *rdn, const int notypes );
-#endif
#ifdef MEMPOOL_EXPERIMENTAL
void _free_wrapper(void *ptr)
@@ -1094,21 +1092,13 @@ done:
char **
slapi_ldap_explode_rdn(const char *rdn, int notypes)
{
-#if defined(USE_OPENLDAP)
return mozldap_ldap_explode_rdn(rdn, notypes);
-#else
- return ldap_explode_rdn(rdn, notypes);
-#endif
}
char **
slapi_ldap_explode_dn(const char *dn, int notypes)
{
-#if defined(USE_OPENLDAP)
return mozldap_ldap_explode_dn(dn, notypes);
-#else
- return ldap_explode_dn(dn, notypes);
-#endif
}
void
@@ -1992,14 +1982,15 @@ cleanup:
#endif /* HAVE_KRB5 */
-#if defined(USE_OPENLDAP)
-
#define LDAP_DN 1
#define LDAP_RDN 2
#define INQUOTE 1
#define OUTQUOTE 2
+/* We use the following two functions when built against OpenLDAP
+ * or the MozLDAP libs since the MozLDAP ldap_explode_dn() function
+ * does not handle trailing whitespace characters properly. */
static char **
mozldap_ldap_explode( const char *dn, const int notypes, const int nametype )
{
@@ -2101,8 +2092,7 @@ mozldap_ldap_explode( const char *dn, const int notypes, const int
nametype )
if ( !endquote ) {
/* trim trailing spaces */
while ( len > 0 &&
- ldap_utf8isspace(
- &rdns[count-1][len-1] )) {
+ (rdns[count-1][len-1] == ' ')) {
--len;
}
}
@@ -2148,4 +2138,3 @@ mozldap_ldap_explode_rdn( const char *rdn, const int notypes )
return( mozldap_ldap_explode( rdn, notypes, LDAP_RDN ) );
}
-#endif /* USE_OPENLDAP */
Show replies by thread