]> git.sur5r.net Git - openldap/blobdiff - clients/ud/find.c
Fix format %x -> %lx in des_string_to_key
[openldap] / clients / ud / find.c
index 9fe2442f0b31f45b89dd375c07fcc09861f9d58f..437c78fbff7b25f01719c91d28a4906960e982e1 100644 (file)
@@ -13,7 +13,8 @@
 #include "portable.h"
 
 #include <stdio.h>
-#include <stdlib.h>            /* get atoi() */
+
+#include <ac/stdlib.h>
 
 #include <ac/ctype.h>
 #include <ac/string.h>
@@ -221,7 +222,10 @@ find( char *who, int quiet )
                        ldap_set_option(ld, LDAP_OPT_DEREF, &savederef);
                        return(NULL);
                } else if (matches == 1) {
-                       if (ldap_search_s(ld, ldap_get_dn(ld, ldap_first_entry(ld, res)), LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
+                       dn = ldap_get_dn(ld, ldap_first_entry(ld, res));
+                       rc = ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res);
+                       ldap_memfree(dn);
+                       if (rc != LDAP_SUCCESS) {
                                int ld_errno = 0;
                                ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &ld_errno);
                                if (ld_errno == LDAP_UNAVAILABLE)
@@ -287,7 +291,10 @@ find( char *who, int quiet )
                                fflush(stdout);
                                fetch_buffer(response, sizeof(response), stdin);
                                if ((response[0] == 'n') || (response[0] == 'N'))
+                               {
+                                       ldap_memfree(dn);
                                        return(NULL);
+                               }
                        }
 #ifdef DEBUG
                        if (debug & D_FIND) {
@@ -306,9 +313,9 @@ find( char *who, int quiet )
                        if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE, "objectClass=*", read_attrs, FALSE, &res) != LDAP_SUCCESS) {
                                ldap_perror(ld, "ldap_search_s");
                                ldap_msgfree(res);
-                               return(NULL);
+                               res = NULL;
                        }
-                       Free(dn);
+                       ldap_memfree(dn);
                        return(res);
                }
                else if (matches > 0) {
@@ -349,7 +356,7 @@ pick_one( int i )
 }
 
 void
-print_list( LDAPMessage *list, char *names[], int *matches )
+print_list( LDAPMessage *list, char **names, int *matches )
 {
        char **rdns, **cpp;
        char resp[SMALL_BUF_SIZE];
@@ -392,10 +399,11 @@ again:
        }
        *matches = i - 1;
        names[i] = NULL;
+       return;
 }
 
 int
-find_all_subscribers( char *sub[], char *group )
+find_all_subscribers( char **sub, char *group )
 {
        int count;
        LDAPMessage *result;