summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/libsmb/cli_lsarpc.c54
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);