diff options
author | Tim Potter <tpot@samba.org> | 2001-06-22 02:15:02 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2001-06-22 02:15:02 +0000 |
commit | df07df9ffce69551105dfd1334d33f69de4442b7 (patch) | |
tree | dbbbeed7b899534539d05eeac805e7e9fb290abf | |
parent | 147af5f3186e5896c59602e5fba5a27673910c8a (diff) | |
download | samba-df07df9ffce69551105dfd1334d33f69de4442b7.tar.gz samba-df07df9ffce69551105dfd1334d33f69de4442b7.tar.bz2 samba-df07df9ffce69551105dfd1334d33f69de4442b7.zip |
Cleanup of cli_lsa_enum_trust_dom(). talloc() doesn't like attempts to
allocate 0 bytes.
(This used to be commit 465994cfbca72649474345bc057d436961cccf97)
-rw-r--r-- | source3/libsmb/cli_lsarpc.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/source3/libsmb/cli_lsarpc.c b/source3/libsmb/cli_lsarpc.c index 00c5ac9a16..88f0dff225 100644 --- a/source3/libsmb/cli_lsarpc.c +++ b/source3/libsmb/cli_lsarpc.c @@ -521,7 +521,12 @@ uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, TALLOC_CTX *mem_ctx, result = r.status; - if (result != NT_STATUS_NOPROBLEMO && result != 0x8000001a) { + /* For some undocumented reason this function sometimes returns + 0x8000001a (NT_STATUS_UNABLE_TO_FREE_VM) so we ignore it and + pretend everything is OK. */ + + if (result != NT_STATUS_NOPROBLEMO && + result != NT_STATUS_UNABLE_TO_FREE_VM) { /* An actual error ocured */ @@ -532,33 +537,42 @@ uint32 cli_lsa_enum_trust_dom(struct cli_state *cli, TALLOC_CTX *mem_ctx, /* Return output parameters */ - if (!((*domain_names) = (char **)talloc(mem_ctx, sizeof(char *) * - r.num_domains))) { - DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n")); - result = NT_STATUS_UNSUCCESSFUL; - goto done; - } + if (r.num_domains) { - if (!((*domain_sids) = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) * - r.num_domains))) { - DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n")); - result = NT_STATUS_UNSUCCESSFUL; - goto done; - } + /* Allocate memory for trusted domain names and sids */ - for (i = 0; i < r.num_domains; i++) { - fstring tmp; + *domain_names = (char **)talloc(mem_ctx, sizeof(char *) * + r.num_domains); - unistr2_to_ascii(tmp, &r.uni_domain_name[i], sizeof(tmp) - 1); - (*domain_names)[i] = strdup(tmp); - sid_copy(&(*domain_sids)[i], &r.domain_sid[i].sid); + if (!*domain_names) { + DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n")); + result = NT_STATUS_UNSUCCESSFUL; + goto done; + } + + *domain_sids = (DOM_SID *)talloc(mem_ctx, sizeof(DOM_SID) * + r.num_domains); + if (!domain_sids) { + DEBUG(0, ("cli_lsa_enum_trust_dom(): out of memory\n")); + result = NT_STATUS_UNSUCCESSFUL; + goto done; + } + + /* Copy across names and sids */ + + for (i = 0; i < r.num_domains; i++) { + fstring tmp; + + unistr2_to_ascii(tmp, &r.uni_domain_name[i], + sizeof(tmp) - 1); + (*domain_names)[i] = strdup(tmp); + sid_copy(&(*domain_sids)[i], &r.domain_sid[i].sid); + } } *num_domains = r.num_domains; *enum_ctx = r.enum_context; - lsa_free_r_enum_trust_dom(&r); - done: prs_mem_free(&qbuf); prs_mem_free(&rbuf); |