r15492: Without this patch, the LDAP client libs will call abort() in
authorAndrew Bartlett <abartlet@samba.org>
Sun, 7 May 2006 15:05:32 +0000 (15:05 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:16:54 +0000 (11:16 -0500)
ldap_get_values_len, because they were handed a NULL msgs pointer, for
example in ads_pull_sid().

This occurs when the AD server fails at the connect stage.  (The
toubled AD server is actually Samba4 in my example).

Andrew Bartlett

source/libads/ldap_utils.c

index 105fd2e5b9d124a479fb98d0e1f96cafdbcf5575..58f1c20ad2560cbcabd12d15aba9154e3596a11a 100644 (file)
@@ -48,15 +48,16 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
                return ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
        }
 
-       while (count--) {
-               *res = NULL;
-               status = ads_do_search_all(ads, bp, scope, expr, attrs, res);
-               if (ADS_ERR_OK(status)) {
-                       DEBUG(5,("Search for %s gave %d replies\n",
-                                expr, ads_count_replies(ads, *res)));
-                       SAFE_FREE(bp);
-                       return status;
-               }
+       *res = NULL;
+       status = ads_do_search_all(ads, bp, scope, expr, attrs, res);
+       if (ADS_ERR_OK(status)) {
+               DEBUG(5,("Search for %s gave %d replies\n",
+                        expr, ads_count_replies(ads, *res)));
+               SAFE_FREE(bp);
+               return status;
+       }
+
+       while (--count) {
 
                if (*res) 
                        ads_msgfree(ads, *res);
@@ -79,6 +80,15 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
                        SAFE_FREE(bp);
                        return status;
                }
+
+               *res = NULL;
+               status = ads_do_search_all(ads, bp, scope, expr, attrs, res);
+               if (ADS_ERR_OK(status)) {
+                       DEBUG(5,("Search for %s gave %d replies\n",
+                                expr, ads_count_replies(ads, *res)));
+                       SAFE_FREE(bp);
+                       return status;
+               }
        }
         SAFE_FREE(bp);