From c4a8a3dce53937869c5dfc0562a969113495b84a Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Tue, 13 Aug 2002 17:00:33 +0000 Subject: [PATCH] better error handling when returning results --- servers/slapd/back-ldap/search.c | 17 ++++++++++------- servers/slapd/back-meta/search.c | 19 +++++++++++-------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/servers/slapd/back-ldap/search.c b/servers/slapd/back-ldap/search.c index 45c5bd43df..c2e278d5c7 100644 --- a/servers/slapd/back-ldap/search.c +++ b/servers/slapd/back-ldap/search.c @@ -48,7 +48,7 @@ #undef ldap_debug /* silence a warning in ldap-int.h */ #include "../../../libraries/libldap/ldap-int.h" -static void ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc, +static int ldap_send_entry( Backend *be, Operation *op, struct ldapconn *lc, LDAPMessage *e, AttributeName *attrs, int attrsonly ); int @@ -272,8 +272,9 @@ fail:; ldap_pvt_thread_yield(); } else if (rc == LDAP_RES_SEARCH_ENTRY) { e = ldap_first_entry(lc->ld,res); - ldap_send_entry(be, op, lc, e, attrs, attrsonly); - count++; + if ( ldap_send_entry(be, op, lc, e, attrs, attrsonly) == LDAP_SUCCESS ) { + count++; + } ldap_msgfree(res); } else { sres = ldap_result2error(lc->ld, res, 1); @@ -353,7 +354,7 @@ finish:; return rc; } -static void +static int ldap_send_entry( Backend *be, Operation *op, @@ -373,7 +374,7 @@ ldap_send_entry( const char *text; if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) { - return; + return LDAP_DECODING_ERROR; } #ifdef ENABLE_REWRITE @@ -400,7 +401,7 @@ ldap_send_entry( case REWRITE_REGEXEC_ERR: case REWRITE_REGEXEC_UNWILLING: - return; + return LDAP_OTHER; } #else /* !ENABLE_REWRITE */ ldap_back_dn_massage( li, &bdn, &ent.e_name, 0, 0 ); @@ -414,7 +415,7 @@ ldap_send_entry( * FIXME: should we log anything, or delegate to dnNormalize2? */ if ( dnNormalize2( NULL, &ent.e_name, &ent.e_nname ) != LDAP_SUCCESS ) { - return; + return LDAP_INVALID_DN_SYNTAX; } ent.e_id = 0; @@ -560,4 +561,6 @@ ldap_send_entry( free( ent.e_dn ); if ( ent.e_ndn ) free( ent.e_ndn ); + + return LDAP_SUCCESS; } diff --git a/servers/slapd/back-meta/search.c b/servers/slapd/back-meta/search.c index a670ef415c..4bab7a31f8 100644 --- a/servers/slapd/back-meta/search.c +++ b/servers/slapd/back-meta/search.c @@ -80,7 +80,7 @@ #include "ldap_log.h" #include "../../../libraries/libldap/ldap-int.h" -static void +static int meta_send_entry( Backend *be, Operation *op, @@ -445,9 +445,10 @@ meta_back_search( goto finish; } else if ( rc == LDAP_RES_SEARCH_ENTRY ) { e = ldap_first_entry( lsc->ld, res ); - meta_send_entry(be, op, lc, i, e, attrs, - attrsonly); - count++; + if ( meta_send_entry( be, op, lc, i, e, attrs, + attrsonly ) == LDAP_SUCCESS ) { + count++; + } ldap_msgfree( res ); gotit = 1; } else { @@ -569,7 +570,7 @@ finish:; return rc; } -static void +static int meta_send_entry( Backend *be, Operation *op, @@ -590,7 +591,7 @@ meta_send_entry( const char *text; if ( ber_scanf( &ber, "{m{", &bdn ) == LBER_ERROR ) { - return; + return LDAP_DECODING_ERROR; } /* @@ -617,7 +618,7 @@ meta_send_entry( case REWRITE_REGEXEC_ERR: case REWRITE_REGEXEC_UNWILLING: - return; + return LDAP_OTHER; } /* @@ -628,7 +629,7 @@ meta_send_entry( * FIXME: should we log anything, or delegate to dnNormalize2? */ if ( dnNormalize2( NULL, &ent.e_name, &ent.e_nname ) != LDAP_SUCCESS ) { - return; + return LDAP_INVALID_DN_SYNTAX; } /* @@ -782,6 +783,8 @@ meta_send_entry( if ( ent.e_ndn ) { free( ent.e_ndn ); } + + return LDAP_SUCCESS; } static int -- 2.39.5