summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-11-15 18:57:22 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:17 -0500
commitaad0bc6c3782099d7eb070450863663ce5d77050 (patch)
treee3b38657d82d8cc9efd883c2c63e190d7aa6dbc3 /source3
parentb87a0af812442385111bfca2055a65fc12027e58 (diff)
downloadsamba-aad0bc6c3782099d7eb070450863663ce5d77050.tar.gz
samba-aad0bc6c3782099d7eb070450863663ce5d77050.tar.bz2
samba-aad0bc6c3782099d7eb070450863663ce5d77050.zip
r3764: Ensure on failure that *res is always NULL.
Check for malloc fail. Fixes for bug #2036. Jeremy. (This used to be commit b815247747214ba413c054746e9732d5f2b10535)
Diffstat (limited to 'source3')
-rw-r--r--source3/libads/ldap.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index b2ae5aeb94..252cd718c8 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -456,8 +456,6 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
controls[1] = &PagedResults;
controls[2] = NULL;
- *res = NULL;
-
/* we need to disable referrals as the openldap libs don't
handle them and paged results at the same time. Using them
together results in the result record containing the server
@@ -533,6 +531,7 @@ ADS_STATUS ads_do_search_all(ADS_STRUCT *ads, const char *bind_path,
int count = 0;
ADS_STATUS status;
+ *res = NULL;
status = ads_do_paged_search(ads, bind_path, scope, expr, attrs, res,
&count, &cookie);
@@ -623,6 +622,7 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope,
char *utf8_expr, *utf8_path, **search_attrs = NULL;
TALLOC_CTX *ctx;
+ *res = NULL;
if (!(ctx = talloc_init("ads_do_search"))) {
DEBUG(1,("ads_do_search: talloc_init() failed!"));
return ADS_ERROR(LDAP_NO_MEMORY);
@@ -653,7 +653,6 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope,
timeout.tv_sec = ADS_SEARCH_TIMEOUT;
timeout.tv_usec = 0;
- *res = NULL;
/* see the note in ads_do_paged_search - we *must* disable referrals */
ldap_set_option(ads->ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF);
@@ -764,6 +763,8 @@ ADS_STATUS ads_find_machine_acct(ADS_STRUCT *ads, void **res, const char *machin
char *expr;
const char *attrs[] = {"*", "nTSecurityDescriptor", NULL};
+ *res = NULL;
+
/* the easiest way to find a machine account anywhere in the tree
is to look for hostname$ */
if (asprintf(&expr, "(samAccountName=%s$)", machine) == -1) {
@@ -2494,6 +2495,10 @@ ADS_STATUS ads_workgroup_name(ADS_STRUCT *ads, TALLOC_CTX *mem_ctx, const char *
asprintf(&expr, "(&(objectclass=computer)(dnshostname=%s.%s))",
ads->config.ldap_server_name, ads->config.realm);
+ if (expr == NULL) {
+ ADS_ERROR_NT(NT_STATUS_NO_MEMORY);
+ }
+
rc = ads_search(ads, &res, expr, attrs);
free(expr);