summaryrefslogtreecommitdiff
path: root/source3/libads/ldap_utils.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-01-05 02:12:38 +0000
committerAndrew Bartlett <abartlet@samba.org>2004-01-05 02:12:38 +0000
commit3c2371dcfc83ef7b9605e7450cdf8945723a3d1e (patch)
tree9f0ffadc6bf49bb464bc81cc89c2e284c99fc16e /source3/libads/ldap_utils.c
parentaf8fb7e01e44b4569641ea7d9eb21cbc7d782121 (diff)
downloadsamba-3c2371dcfc83ef7b9605e7450cdf8945723a3d1e.tar.gz
samba-3c2371dcfc83ef7b9605e7450cdf8945723a3d1e.tar.bz2
samba-3c2371dcfc83ef7b9605e7450cdf8945723a3d1e.zip
There is some memory corruption hidden somewhere in our winbind code. If I
could reproduce it, I would fix it, but for now just make sure we always SAFE_FREE() and set our starting pointers to NULL. Andrew Bartlett (This used to be commit c279e178bc122e1e2aa519f7a373a3d93672a3ac)
Diffstat (limited to 'source3/libads/ldap_utils.c')
-rw-r--r--source3/libads/ldap_utils.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source3/libads/ldap_utils.c b/source3/libads/ldap_utils.c
index 4142bceabc..991f16c845 100644
--- a/source3/libads/ldap_utils.c
+++ b/source3/libads/ldap_utils.c
@@ -35,6 +35,8 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
int count = 3;
char *bp;
+ *res = NULL;
+
if (!ads->ld &&
time(NULL) - ads->last_attempt < ADS_RECONNECT_TIME) {
return ADS_ERROR(LDAP_SERVER_DOWN);
@@ -42,15 +44,17 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
bp = strdup(bind_path);
- if (!bp)
+ if (!bp) {
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)));
- free(bp);
+ SAFE_FREE(bp);
return status;
}
@@ -72,11 +76,11 @@ ADS_STATUS ads_do_search_retry(ADS_STRUCT *ads, const char *bind_path, int scope
DEBUG(1,("ads_search_retry: failed to reconnect (%s)\n",
ads_errstr(status)));
ads_destroy(&ads);
- free(bp);
+ SAFE_FREE(bp);
return status;
}
}
- free(bp);
+ SAFE_FREE(bp);
if (!ADS_ERR_OK(status))
DEBUG(1,("ads reopen failed after error %s\n",