]> git.sur5r.net Git - openldap/commitdiff
improve previous commit (one line, use buffer and truncate if required)
authorPierangelo Masarati <ando@openldap.org>
Fri, 16 Dec 2005 12:18:55 +0000 (12:18 +0000)
committerPierangelo Masarati <ando@openldap.org>
Fri, 16 Dec 2005 12:18:55 +0000 (12:18 +0000)
libraries/libldap/search.c

index 57647d92f1db53d5708ec6a8406062407d53a9e2..6798f7830fe015da2e79f0e5253fc4910690de50 100644 (file)
@@ -300,18 +300,27 @@ ldap_build_search_req(
 
 #ifdef LDAP_DEBUG
        if ( ldap_debug & LDAP_DEBUG_ARGS ) {
-               if ( attrs == NULL ) {
-                       Debug( LDAP_DEBUG_ARGS, "ldap_build_search_req ATTRS: *\n", 0, 0, 0 );
-                       
-               } else {
-                       int     i;
+               char    buf[ BUFSIZ ] = { ' ', '*', '\0' };
 
-                       Debug( LDAP_DEBUG_ARGS, "ldap_build_search_req ATTRS:\n", 0, 0, 0 );
+               if ( attrs != NULL ) {
+                       char    *ptr;
+                       int     i;
 
-                       for ( i = 0; attrs[ i ]; i++ ) {
-                               Debug( LDAP_DEBUG_ARGS, "    %s\n", attrs[ i ], 0, 0 );
+                       for ( ptr = buf, i = 0;
+                               attrs[ i ] != NULL && ptr < &buf[ sizeof( buf ) ];
+                               i++ )
+                       {
+                               ptr += snprintf( ptr, sizeof( buf ) - ( ptr - buf ),
+                                       " %s", attrs[ i ] );
                        }
+
+                       if ( ptr >= &buf[ sizeof( buf ) ] ) {
+                               AC_MEMCPY( &buf[ sizeof( buf ) - STRLENOF( "...(truncated)" ) - 1 ],
+                                       "...(truncated)", STRLENOF( "...(truncated)" ) + 1 );
+                       } 
                }
+
+               Debug( LDAP_DEBUG_ARGS, "ldap_build_search_req ATTRS:%s\n", buf, 0, 0 );
        }
 #endif /* LDAP_DEBUG */