mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-23 16:19:35 -05:00
check consistency of referrals and result code (ITS#4861)
This commit is contained in:
parent
d07f85fc91
commit
6a9c44849c
4 changed files with 159 additions and 73 deletions
|
|
@ -1673,7 +1673,21 @@ retry:;
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
rs->sr_err = rc;
|
rs->sr_err = rc;
|
||||||
}
|
}
|
||||||
if ( refs != NULL ) {
|
|
||||||
|
/* RFC 4511: referrals can only appear
|
||||||
|
* if result code is LDAP_REFERRAL */
|
||||||
|
if ( refs != NULL
|
||||||
|
&& refs[ 0 ] != NULL
|
||||||
|
&& refs[ 0 ][ 0 ] != '\0' )
|
||||||
|
{
|
||||||
|
if ( rs->sr_err != LDAP_REFERRAL ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s ldap_back_op_result: "
|
||||||
|
"got referrals with err=%d\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
rs->sr_err, 0 );
|
||||||
|
|
||||||
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for ( i = 0; refs[ i ] != NULL; i++ )
|
for ( i = 0; refs[ i ] != NULL; i++ )
|
||||||
|
|
@ -1685,6 +1699,20 @@ retry:;
|
||||||
}
|
}
|
||||||
BER_BVZERO( &rs->sr_ref[ i ] );
|
BER_BVZERO( &rs->sr_ref[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if ( rs->sr_err == LDAP_REFERRAL ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s ldap_back_op_result: "
|
||||||
|
"got err=%d with null "
|
||||||
|
"or empty referrals\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
rs->sr_err, 0 );
|
||||||
|
|
||||||
|
rs->sr_err = LDAP_NO_SUCH_OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ber_memvfree( (void **)refs );
|
||||||
|
|
||||||
if ( ctrls != NULL ) {
|
if ( ctrls != NULL ) {
|
||||||
rs->sr_ctrls = ctrls;
|
rs->sr_ctrls = ctrls;
|
||||||
}
|
}
|
||||||
|
|
@ -1739,8 +1767,6 @@ retry:;
|
||||||
rs->sr_text = NULL;
|
rs->sr_text = NULL;
|
||||||
|
|
||||||
if ( rs->sr_ref ) {
|
if ( rs->sr_ref ) {
|
||||||
assert( refs != NULL );
|
|
||||||
ber_memvfree( (void **)refs );
|
|
||||||
op->o_tmpfree( rs->sr_ref, op->o_tmpmemctx );
|
op->o_tmpfree( rs->sr_ref, op->o_tmpmemctx );
|
||||||
rs->sr_ref = NULL;
|
rs->sr_ref = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -420,18 +420,21 @@ retry:
|
||||||
freetext = 1;
|
freetext = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( references && references[ 0 ] && references[ 0 ][ 0 ] ) {
|
/* RFC 4511: referrals can only appear
|
||||||
int cnt;
|
* if result code is LDAP_REFERRAL */
|
||||||
|
if ( references
|
||||||
|
&& references[ 0 ]
|
||||||
|
&& references[ 0 ][ 0 ] )
|
||||||
|
{
|
||||||
if ( rs->sr_err != LDAP_REFERRAL ) {
|
if ( rs->sr_err != LDAP_REFERRAL ) {
|
||||||
/* FIXME: error */
|
|
||||||
Debug( LDAP_DEBUG_ANY,
|
Debug( LDAP_DEBUG_ANY,
|
||||||
"%s ldap_back_search: "
|
"%s ldap_back_search: "
|
||||||
"got referrals with %d\n",
|
"got referrals with err=%d\n",
|
||||||
op->o_log_prefix,
|
op->o_log_prefix,
|
||||||
rs->sr_err, 0 );
|
rs->sr_err, 0 );
|
||||||
rs->sr_err = LDAP_REFERRAL;
|
|
||||||
}
|
} else {
|
||||||
|
int cnt;
|
||||||
|
|
||||||
for ( cnt = 0; references[ cnt ]; cnt++ )
|
for ( cnt = 0; references[ cnt ]; cnt++ )
|
||||||
/* NO OP */ ;
|
/* NO OP */ ;
|
||||||
|
|
@ -446,13 +449,21 @@ retry:
|
||||||
BER_BVZERO( &rs->sr_ref[ cnt ] );
|
BER_BVZERO( &rs->sr_ref[ cnt ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( match.bv_val != NULL ) {
|
} else if ( rs->sr_err == LDAP_REFERRAL ) {
|
||||||
match.bv_len = strlen( match.bv_val );
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s ldap_back_search: "
|
||||||
|
"got err=%d with null "
|
||||||
|
"or empty referrals\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
rs->sr_err, 0 );
|
||||||
|
|
||||||
|
rs->sr_err = LDAP_NO_SUCH_OBJECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
if ( references ) {
|
|
||||||
ber_memvfree( (void **)references );
|
ber_memvfree( (void **)references );
|
||||||
|
|
||||||
|
if ( match.bv_val != NULL ) {
|
||||||
|
match.bv_len = strlen( match.bv_val );
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = 0;
|
rc = 0;
|
||||||
|
|
|
||||||
|
|
@ -1018,7 +1018,21 @@ retry:;
|
||||||
if ( rc != LDAP_SUCCESS ) {
|
if ( rc != LDAP_SUCCESS ) {
|
||||||
rs->sr_err = rc;
|
rs->sr_err = rc;
|
||||||
}
|
}
|
||||||
if ( refs != NULL ) {
|
|
||||||
|
/* RFC 4511: referrals can only appear
|
||||||
|
* if result code is LDAP_REFERRAL */
|
||||||
|
if ( refs != NULL
|
||||||
|
&& refs[ 0 ] != NULL
|
||||||
|
&& refs[ 0 ][ 0 ] != '\0' )
|
||||||
|
{
|
||||||
|
if ( rs->sr_err != LDAP_REFERRAL ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s meta_back_op_result[%d]: "
|
||||||
|
"got referrals with err=%d\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
candidate, rs->sr_err );
|
||||||
|
|
||||||
|
} else {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for ( i = 0; refs[ i ] != NULL; i++ )
|
for ( i = 0; refs[ i ] != NULL; i++ )
|
||||||
|
|
@ -1030,6 +1044,20 @@ retry:;
|
||||||
}
|
}
|
||||||
BER_BVZERO( &rs->sr_ref[ i ] );
|
BER_BVZERO( &rs->sr_ref[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if ( rs->sr_err == LDAP_REFERRAL ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s meta_back_op_result[%d]: "
|
||||||
|
"got err=%d with null "
|
||||||
|
"or empty referrals\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
candidate, rs->sr_err );
|
||||||
|
|
||||||
|
rs->sr_err = LDAP_NO_SUCH_OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
ber_memvfree( (void **)refs );
|
||||||
|
|
||||||
if ( ctrls != NULL ) {
|
if ( ctrls != NULL ) {
|
||||||
rs->sr_ctrls = ctrls;
|
rs->sr_ctrls = ctrls;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -870,7 +870,6 @@ getconn:;
|
||||||
int gotit = 0,
|
int gotit = 0,
|
||||||
doabandon = 0,
|
doabandon = 0,
|
||||||
alreadybound = ncandidates;
|
alreadybound = ncandidates;
|
||||||
time_t curr_time = 0;
|
|
||||||
|
|
||||||
/* check timeout */
|
/* check timeout */
|
||||||
if ( timeout && lastres_time > 0
|
if ( timeout && lastres_time > 0
|
||||||
|
|
@ -1243,16 +1242,15 @@ really_bad:;
|
||||||
NULL /* &candidates[ i ].sr_ctrls (unused) */ ,
|
NULL /* &candidates[ i ].sr_ctrls (unused) */ ,
|
||||||
0 );
|
0 );
|
||||||
if ( rs->sr_err != LDAP_SUCCESS ) {
|
if ( rs->sr_err != LDAP_SUCCESS ) {
|
||||||
ldap_get_option( msc->msc_ld,
|
sres = slap_map_api2result( &candidates[ i ] );
|
||||||
LDAP_OPT_ERROR_NUMBER,
|
|
||||||
&rs->sr_err );
|
|
||||||
sres = slap_map_api2result( rs );
|
|
||||||
candidates[ i ].sr_type = REP_RESULT;
|
candidates[ i ].sr_type = REP_RESULT;
|
||||||
ldap_msgfree( res );
|
ldap_msgfree( res );
|
||||||
res = NULL;
|
res = NULL;
|
||||||
goto really_bad;
|
goto really_bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rs->sr_err = candidates[ i ].sr_err;
|
||||||
|
|
||||||
/* massage matchedDN if need be */
|
/* massage matchedDN if need be */
|
||||||
if ( candidates[ i ].sr_matched != NULL ) {
|
if ( candidates[ i ].sr_matched != NULL ) {
|
||||||
struct berval match, mmatch;
|
struct berval match, mmatch;
|
||||||
|
|
@ -1278,7 +1276,20 @@ really_bad:;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add references to array */
|
/* add references to array */
|
||||||
if ( references ) {
|
/* RFC 4511: referrals can only appear
|
||||||
|
* if result code is LDAP_REFERRAL */
|
||||||
|
if ( references != NULL
|
||||||
|
&& references[ 0 ] != NULL
|
||||||
|
&& references[ 0 ][ 0 ] != '\0' )
|
||||||
|
{
|
||||||
|
if ( rs->sr_err != LDAP_REFERRAL ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s meta_back_search[%ld]: "
|
||||||
|
"got referrals with err=%d\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
i, rs->sr_err );
|
||||||
|
|
||||||
|
} else {
|
||||||
BerVarray sr_ref;
|
BerVarray sr_ref;
|
||||||
int cnt;
|
int cnt;
|
||||||
|
|
||||||
|
|
@ -1294,9 +1305,6 @@ really_bad:;
|
||||||
|
|
||||||
( void )ldap_back_referral_result_rewrite( &dc, sr_ref );
|
( void )ldap_back_referral_result_rewrite( &dc, sr_ref );
|
||||||
|
|
||||||
/* cleanup */
|
|
||||||
ber_memvfree( (void **)references );
|
|
||||||
|
|
||||||
if ( rs->sr_v2ref == NULL ) {
|
if ( rs->sr_v2ref == NULL ) {
|
||||||
rs->sr_v2ref = sr_ref;
|
rs->sr_v2ref = sr_ref;
|
||||||
|
|
||||||
|
|
@ -1308,7 +1316,20 @@ really_bad:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rs->sr_err = candidates[ i ].sr_err;
|
} else if ( rs->sr_err == LDAP_REFERRAL ) {
|
||||||
|
Debug( LDAP_DEBUG_ANY,
|
||||||
|
"%s meta_back_search[%ld]: "
|
||||||
|
"got err=%d with null "
|
||||||
|
"or empty referrals\n",
|
||||||
|
op->o_log_prefix,
|
||||||
|
i, rs->sr_err );
|
||||||
|
|
||||||
|
rs->sr_err = LDAP_NO_SUCH_OBJECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
ber_memvfree( (void **)references );
|
||||||
|
|
||||||
sres = slap_map_api2result( rs );
|
sres = slap_map_api2result( rs );
|
||||||
|
|
||||||
if ( LogTest( LDAP_DEBUG_TRACE | LDAP_DEBUG_ANY ) ) {
|
if ( LogTest( LDAP_DEBUG_TRACE | LDAP_DEBUG_ANY ) ) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue