From: Jong Hyuk Choi Date: Wed, 17 Sep 2003 23:06:57 +0000 (+0000) Subject: missing or empty attrs list in a syncrepl specification X-Git-Tag: OPENLDAP_REL_ENG_2_1_MP~710 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a0331a048796247b64860bd7549f51d862d7e500;p=openldap missing or empty attrs list in a syncrepl specification is changed to mean attrs="*" --- diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 36a77183fc..a175a34999 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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++ ) {