check for NULL dn in URL; set error code before seding extended response (partially addresses ITS#4968)

This commit is contained in:
Pierangelo Masarati 2007-05-15 22:29:06 +00:00
parent d9a43aee44
commit c30ae47206

View File

@ -418,7 +418,7 @@ ldap_chain_op(
LDAPURLDesc *srv = NULL; LDAPURLDesc *srv = NULL;
struct berval save_req_dn = op->o_req_dn, struct berval save_req_dn = op->o_req_dn,
save_req_ndn = op->o_req_ndn, save_req_ndn = op->o_req_ndn,
dn, dn = BER_BVNULL,
pdn = BER_BVNULL, pdn = BER_BVNULL,
ndn = BER_BVNULL; ndn = BER_BVNULL;
int temporary = 0; int temporary = 0;
@ -449,17 +449,24 @@ Document: RFC 4511
} }
/* normalize DN */ /* normalize DN */
ber_str2bv( srv->lud_dn, 0, 0, &dn ); rc = LDAP_SUCCESS;
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, op->o_tmpmemctx ); srv->lud_scope = LDAP_SCOPE_DEFAULT;
if ( rc == LDAP_SUCCESS ) { if ( srv->lud_dn != NULL ) {
/* remove DN essentially because later on ber_str2bv( srv->lud_dn, 0, 0, &dn );
* ldap_initialize() will parse the URL rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, op->o_tmpmemctx );
* as a comma-separated URL list */ if ( rc == LDAP_SUCCESS ) {
/* remove DN essentially because later on
* ldap_initialize() will parse the URL
* as a comma-separated URL list */
srv->lud_dn = "";
}
} else {
srv->lud_dn = ""; srv->lud_dn = "";
srv->lud_scope = LDAP_SCOPE_DEFAULT;
li.li_uri = ldap_url_desc2str( srv );
srv->lud_dn = dn.bv_val;
} }
li.li_uri = ldap_url_desc2str( srv );
srv->lud_dn = dn.bv_val;
ldap_free_urldesc( srv ); ldap_free_urldesc( srv );
if ( rc != LDAP_SUCCESS ) { if ( rc != LDAP_SUCCESS ) {
@ -629,16 +636,19 @@ ldap_chain_search(
} }
/* normalize DN */ /* normalize DN */
ber_str2bv( srv->lud_dn, 0, 0, &dn ); rc = LDAP_INVALID_SYNTAX;
rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, op->o_tmpmemctx ); if ( srv->lud_dn != NULL ) {
if ( rc == LDAP_SUCCESS ) { ber_str2bv( srv->lud_dn, 0, 0, &dn );
/* remove DN essentially because later on rc = dnPrettyNormal( NULL, &dn, &pdn, &ndn, op->o_tmpmemctx );
* ldap_initialize() will parse the URL if ( rc == LDAP_SUCCESS ) {
* as a comma-separated URL list */ /* remove DN essentially because later on
srv->lud_dn = ""; * ldap_initialize() will parse the URL
srv->lud_scope = LDAP_SCOPE_DEFAULT; * as a comma-separated URL list */
li.li_uri = ldap_url_desc2str( srv ); srv->lud_dn = "";
srv->lud_dn = dn.bv_val; srv->lud_scope = LDAP_SCOPE_DEFAULT;
li.li_uri = ldap_url_desc2str( srv );
srv->lud_dn = dn.bv_val;
}
} }
ldap_free_urldesc( srv ); ldap_free_urldesc( srv );
@ -918,6 +928,7 @@ ldap_chain_response( Operation *op, SlapReply *rs )
* to send it... */ * to send it... */
/* FIXME: what about chaining? */ /* FIXME: what about chaining? */
if ( rc != SLAPD_ABANDON ) { if ( rc != SLAPD_ABANDON ) {
rs->sr_err = rc;
send_ldap_extended( op, rs ); send_ldap_extended( op, rs );
rc = LDAP_SUCCESS; rc = LDAP_SUCCESS;
} }