Commit 6dbd7341 authored by Pierangelo Masarati's avatar Pierangelo Masarati
Browse files

use berval

parent 6ef22ccd
...@@ -68,7 +68,7 @@ ldap_back_search( ...@@ -68,7 +68,7 @@ ldap_back_search(
struct timeval tv; struct timeval tv;
LDAPMessage *res, *e; LDAPMessage *res, *e;
int rc = 0, msgid; int rc = 0, msgid;
char *match = NULL; struct berval match = { 0, NULL };
char **mapped_attrs = NULL; char **mapped_attrs = NULL;
struct berval mbase; struct berval mbase;
struct berval mfilter = { 0, NULL }; struct berval mfilter = { 0, NULL };
...@@ -297,8 +297,9 @@ fail:; ...@@ -297,8 +297,9 @@ fail:;
} }
} else { } else {
rc = ldap_parse_result(lc->ld, res, &rs->sr_err, &match, rc = ldap_parse_result(lc->ld, res, &rs->sr_err,
(char **)&rs->sr_text, NULL, NULL, 1); &match.bv_val, (char **)&rs->sr_text,
NULL, NULL, 1);
if (rc != LDAP_SUCCESS ) rs->sr_err = rc; if (rc != LDAP_SUCCESS ) rs->sr_err = rc;
rs->sr_err = ldap_back_map_result(rs); rs->sr_err = ldap_back_map_result(rs);
rc = 0; rc = 0;
...@@ -312,8 +313,8 @@ fail:; ...@@ -312,8 +313,8 @@ fail:;
/* /*
* Rewrite the matched portion of the search base, if required * Rewrite the matched portion of the search base, if required
*/ */
if ( match && *match ) { if ( match.bv_val && *match.bv_val ) {
struct berval dn, mdn; struct berval mdn;
#ifdef ENABLE_REWRITE #ifdef ENABLE_REWRITE
dc.ctx = "matchedDn"; dc.ctx = "matchedDn";
...@@ -321,8 +322,8 @@ fail:; ...@@ -321,8 +322,8 @@ fail:;
dc.tofrom = 0; dc.tofrom = 0;
dc.normalized = 0; dc.normalized = 0;
#endif #endif
ber_str2bv(match, 0, 0, &dn); match.bv_len = strlen( match.bv_val );
ldap_back_dn_massage(&dc, &dn, &mdn); ldap_back_dn_massage(&dc, &match, &mdn);
rs->sr_matched = mdn.bv_val; rs->sr_matched = mdn.bv_val;
} }
if ( rs->sr_v2ref ) { if ( rs->sr_v2ref ) {
...@@ -332,12 +333,12 @@ fail:; ...@@ -332,12 +333,12 @@ fail:;
finish:; finish:;
send_ldap_result( op, rs ); send_ldap_result( op, rs );
if ( match ) { if ( match.bv_val ) {
if ( rs->sr_matched != match ) { if ( rs->sr_matched != match.bv_val ) {
free( (char *)rs->sr_matched ); free( (char *)rs->sr_matched );
} }
rs->sr_matched = NULL; rs->sr_matched = NULL;
LDAP_FREE(match); LDAP_FREE( match.bv_val );
} }
if ( rs->sr_text ) { if ( rs->sr_text ) {
LDAP_FREE( (char *)rs->sr_text ); LDAP_FREE( (char *)rs->sr_text );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment