From: Pierangelo Masarati Date: Thu, 17 Apr 2003 21:48:57 +0000 (+0000) Subject: don't return referral if cannot compute one (should fix ITS#2435) X-Git-Tag: OPENLDAP_REL_ENG_2_2_0ALPHA~328 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9f7c48ab54a55953597eb2287648103255fd8b0a;p=openldap don't return referral if cannot compute one (should fix ITS#2435) --- diff --git a/servers/slapd/add.c b/servers/slapd/add.c index 0274426839..b0bd5091c7 100644 --- a/servers/slapd/add.c +++ b/servers/slapd/add.c @@ -313,14 +313,20 @@ do_add( Operation *op, SlapReply *rs ) defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; - rs->sr_ref = referral_rewrite( defref, - NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); + if ( defref != NULL ) { + rs->sr_ref = referral_rewrite( defref, + NULL, &e->e_name, LDAP_SCOPE_DEFAULT ); - rs->sr_err = LDAP_REFERRAL; - if (!rs->sr_ref) rs->sr_ref = default_referral; - send_ldap_result( op, rs ); + rs->sr_err = LDAP_REFERRAL; + if (!rs->sr_ref) rs->sr_ref = default_referral; + send_ldap_result( op, rs ); - if ( rs->sr_ref != default_referral ) ber_bvarray_free( rs->sr_ref ); + if ( rs->sr_ref != default_referral ) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, + LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } #endif /* SLAPD_MULTIMASTER */ } } else { diff --git a/servers/slapd/delete.c b/servers/slapd/delete.c index db30af78b9..facf238f44 100644 --- a/servers/slapd/delete.c +++ b/servers/slapd/delete.c @@ -199,14 +199,20 @@ do_delete( } else { BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; - rs->sr_ref = referral_rewrite( default_referral, - NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - - if (!rs->sr_ref) rs->sr_ref = defref; - rs->sr_err = LDAP_REFERRAL; - send_ldap_result( op, rs ); - - if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref ); + if ( defref != NULL ) { + rs->sr_ref = referral_rewrite( default_referral, + NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); + + if (!rs->sr_ref) rs->sr_ref = defref; + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); + + if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, + LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } #endif } diff --git a/servers/slapd/modify.c b/servers/slapd/modify.c index b6399a9d7a..1aea31a260 100644 --- a/servers/slapd/modify.c +++ b/servers/slapd/modify.c @@ -432,13 +432,25 @@ do_modify( } else { BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; - rs->sr_ref = referral_rewrite( defref, - NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - if (!rs->sr_ref) rs->sr_ref = defref; - rs->sr_err = LDAP_REFERRAL; - send_ldap_result( op, rs ); - if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref ); + if ( defref != NULL ) { + rs->sr_ref = referral_rewrite( defref, + NULL, &op->o_req_dn, + LDAP_SCOPE_DEFAULT ); + + if (!rs->sr_ref) { + rs->sr_ref = defref; + } + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); + if (rs->sr_ref != defref) { + ber_bvarray_free( rs->sr_ref ); + } + } else { + send_ldap_error( op, rs, + LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } #endif } } else { diff --git a/servers/slapd/modrdn.c b/servers/slapd/modrdn.c index 90651da75d..cf4f9e2d31 100644 --- a/servers/slapd/modrdn.c +++ b/servers/slapd/modrdn.c @@ -362,14 +362,20 @@ do_modrdn( } else { BerVarray defref = op->o_bd->be_update_refs ? op->o_bd->be_update_refs : default_referral; - rs->sr_ref = referral_rewrite( defref, - NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); - if (!rs->sr_ref) rs->sr_ref = defref; + if ( defref != NULL ) { + rs->sr_ref = referral_rewrite( defref, + NULL, &op->o_req_dn, LDAP_SCOPE_DEFAULT ); + if (!rs->sr_ref) rs->sr_ref = defref; - rs->sr_err = LDAP_REFERRAL; - send_ldap_result( op, rs ); + rs->sr_err = LDAP_REFERRAL; + send_ldap_result( op, rs ); - if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref ); + if (rs->sr_ref != defref) ber_bvarray_free( rs->sr_ref ); + } else { + send_ldap_error( op, rs, + LDAP_UNWILLING_TO_PERFORM, + "referral missing" ); + } #endif } } else {