]> git.sur5r.net Git - openldap/commitdiff
better error handling when returning results
authorPierangelo Masarati <ando@openldap.org>
Tue, 13 Aug 2002 17:00:33 +0000 (17:00 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 13 Aug 2002 17:00:33 +0000 (17:00 +0000)
servers/slapd/back-ldap/search.c
servers/slapd/back-meta/search.c

index 45c5bd43df769e5a8e8009198d42e093eeabe27e..c2e278d5c7da2d4da400cff694e41c624be0e41f 100644 (file)
@@ -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;
 }
index a670ef415cf8720605cbd65761c7cc7684b7ad97..4bab7a31f8fa9380fcb1fc6e7fe94a60b834cbef 100644 (file)
@@ -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