]> git.sur5r.net Git - openldap/commitdiff
A follow-on commit to the previous @oc support change to use anlist
authorJong Hyuk Choi <jongchoi@openldap.org>
Thu, 23 Sep 2004 19:23:17 +0000 (19:23 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Thu, 23 Sep 2004 19:23:17 +0000 (19:23 +0000)
servers/slapd/ad.c
servers/slapd/backend.c
servers/slapd/config.c
servers/slapd/syncrepl.c

index 6896f9a353f9e5632ab0b0d0d29534bf55f1a2e0..9b5805363edd18c934204253ebe4b7845807eb56 100644 (file)
@@ -811,14 +811,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                        adname.bv_val = &anew->an_name.bv_val[1];
                                        slap_bv2ad(&adname, &anew->an_desc, &text);
                                        if ( !anew->an_desc ) {
-                                               free( an );
-                                               free( str );
-                                               /*
-                                                * overwrites input string
-                                                * on error!
-                                                */
-                                               strcpy( in, s );
-                                               return NULL;
+                                               goto reterr;
                                        }
                                } break;
 
@@ -830,14 +823,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                        ocname.bv_val = &anew->an_name.bv_val[1];
                                        anew->an_oc = oc_bvfind( &ocname );
                                        if ( !anew->an_oc ) {
-                                               free( an );
-                                               free( str );
-                                               /*
-                                                * overwrites input string
-                                                * on error!
-                                                */
-                                               strcpy( in, s );
-                                               return NULL;
+                                               goto reterr;
                                        }
 
                                        if ( anew->an_name.bv_val[0] == '!' ) {
@@ -849,11 +835,7 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
                                /* old (deprecated) way */
                                anew->an_oc = oc_bvfind( &anew->an_name );
                                if ( !anew->an_oc ) {
-                                       free( an );
-                                       free( str );
-                                       /* overwrites input string on error! */
-                                       strcpy( in, s );
-                                       return NULL;
+                                       goto reterr;
                                }
                        }
                }
@@ -863,6 +845,19 @@ str2anlist( AttributeName *an, char *in, const char *brkstr )
        anew->an_name.bv_val = NULL;
        free( str );
        return( an );
+
+reterr:
+       for ( i = 0; an[i].an_name.bv_val; i++ ) {
+               free( an[i].an_name.bv_val );
+       }
+       free( an );
+       /*
+        * overwrites input string
+        * on error!
+        */
+       strcpy( in, s );
+       free( str );
+       return NULL;
 }
 
 char **anlist2charray_x( AttributeName *an, int dup, void *ctx )
@@ -964,7 +959,8 @@ anlist2attrs( AttributeName * anlist )
                }
        }
 
-       attrs = (char **) ch_realloc( attrs, (i+1) * sizeof( char * ));
+       if ( i != n )
+               attrs = (char **) ch_realloc( attrs, (i+1) * sizeof( char * ));
 
        return attrs;
 }
index 4e7d25acda88f1f155fde55d34f8b9dfbed530f8..e6e7675f47f4b2cca540a665e0a4b7ff40d56198 100644 (file)
@@ -483,11 +483,13 @@ int backend_destroy(void)
                        syncinfo_free( si_entry );
                }
 
-               LDAP_TAILQ_FOREACH( csne, bd->be_pending_csn_list, ce_csn_link ) {
-                       LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link );
-                       ch_free( csne->ce_csn->bv_val );
-                       ch_free( csne->ce_csn );
-                       ch_free( csne );
+               if ( bd->be_pending_csn_list ) {
+                       LDAP_TAILQ_FOREACH( csne, bd->be_pending_csn_list, ce_csn_link ) {
+                               LDAP_TAILQ_REMOVE( bd->be_pending_csn_list, csne, ce_csn_link );
+                               ch_free( csne->ce_csn->bv_val );
+                               ch_free( csne->ce_csn );
+                               ch_free( csne );
+                       }
                }
                
                if ( bd->bd_info->bi_db_destroy ) {
index ef307d881138ca81a55636aae9c8d592b6b0e013..0b65dd33df2ed8ced5506133a1a0c0dd40b9555d 100644 (file)
@@ -2312,6 +2312,7 @@ add_syncrepl(
 
        if ( rc < 0 || duplicated_replica_id ) {
                Debug( LDAP_DEBUG_ANY, "failed to add syncinfo\n", 0, 0, 0 );
+               syncinfo_free( si );    
                return 1;
        } else {
                Debug( LDAP_DEBUG_CONFIG,
index 4d7187ced05eb9c523332baeb8f8936deaf89735..7346da5cd342ae03970dab9bc21b121d9b664fb3 100644 (file)
@@ -83,7 +83,9 @@ init_syncrepl(syncinfo_t *si)
                                        i++;
                                }
                        }
-                       attrs = ( char ** ) ch_realloc( attrs, (i + 1)*sizeof( char * ));
+                       attrs = ( char ** ) ch_realloc( attrs, (i + 2)*sizeof( char * ));
+                       attrs[i] = ch_strdup("*");
+                       attrs[i + 1] = NULL;
                } else if ( si->si_allopattrs ) {
                        i = 0;
                        while ( attrs[i] ) {
@@ -97,7 +99,9 @@ init_syncrepl(syncinfo_t *si)
                                        i++;
                                }
                        }
-                       attrs = ( char ** ) ch_realloc( attrs, (i + 1)*sizeof( char * ));
+                       attrs = ( char ** ) ch_realloc( attrs, (i + 2)*sizeof( char * ));
+                       attrs[i] = ch_strdup("+");
+                       attrs[i + 1] = NULL;
                }
 
                if ( !si->si_allopattrs ) {
@@ -143,8 +147,11 @@ init_syncrepl(syncinfo_t *si)
 
        exattrs = anlist2attrs( si->si_exanlist );
 
+
        if ( exattrs ) {
 
+               for ( n = 0; exattrs[n] != NULL; n++ ) ;
+
                for ( i = 0; sync_descs[i] != NULL; i++ ) {
                        j = 0;
                        while ( exattrs[j] != NULL ) {
@@ -181,7 +188,9 @@ init_syncrepl(syncinfo_t *si)
                }
 
                for ( i = 0; exattrs[i] != NULL; i++ ) ;
-               exattrs = (char **) ch_realloc( exattrs, (i + 1)*sizeof(char *));
+
+               if ( i != n )
+                       exattrs = (char **) ch_realloc( exattrs, (i + 1)*sizeof(char *));
        }
 
        si->si_exattrs = exattrs;