From bb305eee0b01440075583774b3a9e5803298ea55 Mon Sep 17 00:00:00 2001 From: Howard Chu Date: Mon, 7 Apr 2003 10:51:57 +0000 Subject: [PATCH] Fix matchedDn detection --- servers/slapd/back-ldap/search.c | 2 +- servers/slapd/back-ldap/suffixmassage.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 31158d7a31..cc4fbe2277 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -317,7 +317,7 @@ fail:; /* * Rewrite the matched portion of the search base, if required */ - if ( match != NULL ) { + if ( match && *match ) { struct berval dn, mdn; #ifdef ENABLE_REWRITE diff --git a/servers/slapd/back-ldap/suffixmassage.c b/servers/slapd/back-ldap/suffixmassage.c index f4a31c1f78..15a8903cf2 100644 --- a/servers/slapd/back-ldap/suffixmassage.c +++ b/servers/slapd/back-ldap/suffixmassage.c @@ -92,12 +92,12 @@ ldap_back_dn_massage( int ldap_back_dn_massage( dncookie *dc, - struct berval *dn, + struct berval *odn, struct berval *res ) { int i, src, dst; - struct berval pretty = {0,NULL}; + struct berval pretty = {0,NULL}, *dn = odn; assert( res ); @@ -157,13 +157,14 @@ ldap_back_dn_massage( break; } } + if (pretty.bv_val) { + ch_free(pretty.bv_val); + dn = odn; + } /* Nothing matched, just return the original DN */ if (res->bv_val == NULL) { *res = *dn; } - if (pretty.bv_val) { - ch_free(pretty.bv_val); - } return 0; } -- 2.39.5