int rc = REWRITE_SUCCESS;
fake_dn.bv_len = STRLENOF("uid=") + input->bv_len;
- fake_dn.bv_val = p = malloc( fake_dn.bv_len );
+ fake_dn.bv_val = p = malloc( fake_dn.bv_len + 1 );
if ( p == NULL ) {
return REWRITE_ERR;
}
memcpy( p, "uid=", STRLENOF("uid=") );
p += STRLENOF("uid=");
memcpy( p, input->bv_val, input->bv_len );
+ fake_dn.bv_val[fake_dn.bv_len] = '\0';
if ( ldap_bv2dn( &fake_dn, &dn, LDAP_DN_FORMAT_LDAPV3 ) != LDAP_SUCCESS ) {
+ free( fake_dn.bv_val );
return REWRITE_ERR;
}
if ( ber_dupbv( output, &dn[0][0]->la_value ) == NULL ) {
rc = REWRITE_ERR;
}
ldap_dnfree( dn );
+ free( fake_dn.bv_val );
return rc;
}
struct berval *output )
{
escape_fn **fns = private;
- struct berval tmpin, tmpout;
+ struct berval tmpin, tmpout = BER_BVNULL;
int i;
assert( private != NULL );
int rc = fns[i]( &tmpin, &tmpout );
free( tmpin.bv_val );
if ( rc != REWRITE_SUCCESS ) {
+ free( tmpout.bv_val );
return rc;
}
tmpin = tmpout;
+ BER_BVZERO( &tmpout );
}
*output = tmpin;