]> git.sur5r.net Git - openldap/commitdiff
missing or empty attrs list in a syncrepl specification
authorJong Hyuk Choi <jongchoi@openldap.org>
Wed, 17 Sep 2003 23:06:57 +0000 (23:06 +0000)
committerJong Hyuk Choi <jongchoi@openldap.org>
Wed, 17 Sep 2003 23:06:57 +0000 (23:06 +0000)
is changed to mean attrs="*"

servers/slapd/syncrepl.c

index 36a77183fcf87cd9c8b470698c1c5b769124ac63..a175a349995c5d454006f4b292d7edc57800c031 100644 (file)
@@ -405,29 +405,23 @@ do_syncrepl(
 
        psub = be->be_nsuffix[0];
 
-       /* Delete Attributes */
-       descs = sync_descs;
+       for ( n = 0; si->attrs[ n ] != NULL; n++ ) ;
 
-       for ( i = 0; descs[i] != NULL; i++ ) {
-               for ( j = 0; si->attrs[j] != NULL; j++ ) {
-                       if ( !strcmp( si->attrs[j], descs[i]->ad_cname.bv_val )) {
-                               ch_free( si->attrs[j] );
-                               for ( k = j; si->attrs[k] != NULL; k++ ) {
-                                       si->attrs[k] = si->attrs[k+1];
+       if ( n != 0 ) {
+               /* Delete Attributes */
+               descs = sync_descs;
+               for ( i = 0; descs[i] != NULL; i++ ) {
+                       for ( j = 0; si->attrs[j] != NULL; j++ ) {
+                               if ( !strcmp( si->attrs[j], descs[i]->ad_cname.bv_val )) {
+                                       ch_free( si->attrs[j] );
+                                       for ( k = j; si->attrs[k] != NULL; k++ ) {
+                                               si->attrs[k] = si->attrs[k+1];
+                                       }
                                }
                        }
                }
-       }
-
-       /* Add Attributes */
-
-       for ( n = 0; si->attrs[ n ] != NULL; n++ ) ;
-       
-       descs = sync_descs;
-
-       for ( i = 0; descs[i] != NULL; i++ ) {
-               tmp = ( char ** ) ch_realloc( si->attrs,
-                               ( n + 3 ) * sizeof( char * ));
+               for ( n = 0; si->attrs[ n ] != NULL; n++ );
+               tmp = ( char ** ) ch_realloc( si->attrs, ( n + 4 ) * sizeof( char * ));
                if ( tmp == NULL ) {
 #ifdef NEW_LOGGING
                        LDAP_LOG( OPERATION, ERR, "out of memory\n", 0,0,0 );
@@ -435,7 +429,24 @@ do_syncrepl(
                        Debug( LDAP_DEBUG_ANY, "out of memory\n", 0,0,0 );
 #endif
                }
-               si->attrs = tmp;
+       } else {
+               tmp = ( char ** ) ch_realloc( si->attrs, 5 * sizeof( char * ));
+               if ( tmp == NULL ) {
+#ifdef NEW_LOGGING
+                       LDAP_LOG( OPERATION, ERR, "out of memory\n", 0,0,0 );
+#else
+                       Debug( LDAP_DEBUG_ANY, "out of memory\n", 0,0,0 );
+#endif
+               }
+               tmp[ n++ ] = ch_strdup( "*" );
+       }
+       
+       descs = sync_descs;
+       si->attrs = tmp;
+
+       /* Add Attributes */
+
+       for ( i = 0; descs[ i ] != NULL; i++ ) {
                si->attrs[ n++ ] = ch_strdup ( descs[i]->ad_cname.bv_val );
                si->attrs[ n ] = NULL;
        }
@@ -1618,10 +1629,15 @@ str2clist( char ***out, char *in, const char *brkstr )
 
        /* find last element in list */
        for (i = 0; *out && *out[i]; i++);
-       
+
        /* protect the input string from strtok */
        str = ch_strdup( in );
 
+       if ( *str == '\0' ) {
+               free( str );
+               return( *out );
+       }
+
        /* Count words in string */
        j=1;
        for ( s = str; *s; s++ ) {