From ccef53677fa741126b0c2590274c896082381123 Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Mon, 1 Oct 2001 16:16:51 +0000 Subject: [PATCH] fix various result returning bugs, mostly related to candidate selction that results in invalid candidates (bug detected by Markus Storm ) --- servers/slapd/back-meta/add.c | 4 +- servers/slapd/back-meta/bind.c | 66 +++++++++++++++------------- servers/slapd/back-meta/candidates.c | 2 +- servers/slapd/back-meta/delete.c | 4 +- servers/slapd/back-meta/modify.c | 4 +- servers/slapd/back-meta/modrdn.c | 13 +++--- servers/slapd/back-meta/search.c | 18 +++++--- 7 files changed, 59 insertions(+), 52 deletions(-) diff --git a/servers/slapd/back-meta/add.c b/servers/slapd/back-meta/add.c index 5e46ad2c2b..f344c793f5 100644 --- a/servers/slapd/back-meta/add.c +++ b/servers/slapd/back-meta/add.c @@ -129,12 +129,12 @@ meta_back_add( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, "Operations error", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/bind.c b/servers/slapd/back-meta/bind.c index 6d2188359e..cc9fc94b88 100644 --- a/servers/slapd/back-meta/bind.c +++ b/servers/slapd/back-meta/bind.c @@ -127,6 +127,8 @@ meta_back_bind( "meta_back_bind: no target for dn %s.\n%s%s", dn, "", ""); #endif /* !NEW_LOGGING */ + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); return -1; } @@ -198,7 +200,7 @@ meta_back_bind( * deal with bind failure ... */ err = ldap_back_map_result( err ); - send_ldap_result( conn, op, err, NULL, "", NULL, NULL ); + send_ldap_result( conn, op, err, NULL, NULL, NULL, NULL ); return -1; } @@ -355,12 +357,14 @@ meta_back_dobind( struct metaconn *lc, Operation *op ) int meta_back_op_result( struct metaconn *lc, Operation *op ) { - int i, err = LDAP_SUCCESS; - char *msg = NULL; - char *match = NULL; + int i, rerr = LDAP_SUCCESS; struct metasingleconn **lsc; for ( i = 0, lsc = lc->conns; lsc[ 0 ] != NULL; ++i, ++lsc ) { + int err = LDAP_SUCCESS; + char *msg = NULL; + char *match = NULL; + ldap_get_option( lsc[ 0 ]->ld, LDAP_OPT_ERROR_NUMBER, &err ); if ( err != LDAP_SUCCESS ) { /* @@ -375,39 +379,39 @@ meta_back_op_result( struct metaconn *lc, Operation *op ) LDAP_OPT_MATCHED_DN, &match ); err = ldap_back_map_result( err ); - /* - * FIXME: need to rewrite "match" (need rwinfo) - */ - send_ldap_result( lc->conn, op, err, match, msg, - NULL, NULL ); - + rerr = err; + } + + /* + * FIXME: need to rewrite "match" (need rwinfo) + */ + send_ldap_result( lc->conn, op, err, match, msg, NULL, NULL ); + #ifdef NEW_LOGGING - LDAP_LOG(( "backend", LDAP_DEBUG_NOTICE, - "meta_back_op_result: target" - " <%d> sending msg \"%s\"" - " (matched \"%s\")\n", - i, ( msg ? msg : "" ), - ( match ? match : "" ) )); + LDAP_LOG(( "backend", LDAP_DEBUG_NOTICE, + "meta_back_op_result: target" + " <%d> sending msg \"%s\"" + " (matched \"%s\")\n", + i, ( msg ? msg : "" ), + ( match ? match : "" ) )); #else /* !NEW_LOGGING */ - Debug(LDAP_DEBUG_ANY, - "==> meta_back_op_result: target" - " <%d> sending msg \"%s\"" - " (matched \"%s\")\n", - i, ( msg ? msg : "" ), - ( match ? match : "" ) ); + Debug(LDAP_DEBUG_ANY, + "==> meta_back_op_result: target" + " <%d> sending msg \"%s\"" + " (matched \"%s\")\n", + i, ( msg ? msg : "" ), + ( match ? match : "" ) ); #endif /* !NEW_LOGGING */ - /* better test the pointers before freeing? */ - if ( match ) { - free( match ); - } - if ( msg ) { - free( msg ); - } - return -1; + /* better test the pointers before freeing? */ + if ( match ) { + free( match ); + } + if ( msg ) { + free( msg ); } } - return ( err == LDAP_SUCCESS ) ? 0 : -1; + return ( rerr == LDAP_SUCCESS ) ? 0 : -1; } diff --git a/servers/slapd/back-meta/candidates.c b/servers/slapd/back-meta/candidates.c index fe08ceda99..ee2bf0171f 100644 --- a/servers/slapd/back-meta/candidates.c +++ b/servers/slapd/back-meta/candidates.c @@ -119,7 +119,7 @@ meta_back_is_candidate( return META_NOT_CANDIDATE; } - if ( strcmp( &nsuffix[ len - ndnlen] , ndn ) == 0 ) { + if ( strcmp( &nsuffix[ len - ndnlen ] , ndn ) == 0 ) { /* * Got it! */ diff --git a/servers/slapd/back-meta/delete.c b/servers/slapd/back-meta/delete.c index 4c22ac89e2..6f47e91fbb 100644 --- a/servers/slapd/back-meta/delete.c +++ b/servers/slapd/back-meta/delete.c @@ -117,12 +117,12 @@ meta_back_delete( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, "Operations error", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/modify.c b/servers/slapd/back-meta/modify.c index a2530a4c08..dd3ea4c3b2 100644 --- a/servers/slapd/back-meta/modify.c +++ b/servers/slapd/back-meta/modify.c @@ -120,12 +120,12 @@ meta_back_modify( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, "Operations error", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/modrdn.c b/servers/slapd/back-meta/modrdn.c index 16b6e7691b..3528a52072 100644 --- a/servers/slapd/back-meta/modrdn.c +++ b/servers/slapd/back-meta/modrdn.c @@ -119,8 +119,7 @@ meta_back_modrdn( * FIXME: is this the correct return code? */ send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", - NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; } @@ -151,14 +150,12 @@ meta_back_modrdn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", - NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, "Operations error", - NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; } } @@ -184,12 +181,12 @@ meta_back_modrdn( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; case REWRITE_REGEXEC_ERR: send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, - NULL, "Operations error", NULL, NULL ); + NULL, NULL, NULL, NULL ); return -1; } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index 2201524057..92c0b8fa54 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -141,6 +141,8 @@ meta_back_search( */ msgid = ch_calloc( sizeof( int ), li->ntargets ); if ( msgid == NULL ) { + send_search_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL, 0 ); return -1; } @@ -315,11 +317,13 @@ meta_back_search( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", - NULL, NULL ); - /* continue to the next case */ + NULL, NULL, NULL, NULL ); + rc = -1; + goto finish; case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); rc = -1; goto finish; } @@ -515,11 +519,13 @@ meta_back_search( case REWRITE_REGEXEC_UNWILLING: send_ldap_result( conn, op, LDAP_UNWILLING_TO_PERFORM, - NULL, "Unwilling to perform", - NULL, NULL ); - /* continue to the next case */ + NULL, NULL, NULL, NULL ); + rc = -1; + goto finish; case REWRITE_REGEXEC_ERR: + send_ldap_result( conn, op, LDAP_OPERATIONS_ERROR, + NULL, NULL, NULL, NULL ); rc = -1; goto finish; } -- 2.39.5