summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2001-05-11 07:04:47 +0000
committerTim Potter <tpot@samba.org>2001-05-11 07:04:47 +0000
commit862fe3b7ede1ff2214e9129e10820d7fa67681bc (patch)
tree7c99713779fa629c32c6b9a5ccd15aee7e6ae697 /source3
parentc61e75e3e56186c250de55c655a548de8ccb71eb (diff)
downloadsamba-862fe3b7ede1ff2214e9129e10820d7fa67681bc.tar.gz
samba-862fe3b7ede1ff2214e9129e10820d7fa67681bc.tar.bz2
samba-862fe3b7ede1ff2214e9129e10820d7fa67681bc.zip
Memory leak fixes plus general cleanup.
(This used to be commit 48688c4592d03d6404631a7d57701f0af38cfb2d)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/cli_lsarpc.c5
-rw-r--r--source3/rpcclient/cmd_lsarpc.c55
2 files changed, 24 insertions, 36 deletions
diff --git a/source3/libsmb/cli_lsarpc.c b/source3/libsmb/cli_lsarpc.c
index f60a0f960c..00c5ac9a16 100644
--- a/source3/libsmb/cli_lsarpc.c
+++ b/source3/libsmb/cli_lsarpc.c
@@ -278,7 +278,7 @@ uint32 cli_lsa_lookup_sids(struct cli_state *cli, TALLOC_CTX *mem_ctx,
"%s%s%s", dom_name, dom_name[0] ?
"\\" : "", name);
- (*names)[i] = strdup(full_name);
+ (*names)[i] = talloc_strdup(mem_ctx, full_name);
(*types)[i] = t_names.name[i].sid_name_use;
} else {
(*names)[i] = NULL;
@@ -436,6 +436,9 @@ uint32 cli_lsa_query_info_policy(struct cli_state *cli, TALLOC_CTX *mem_ctx,
/* Return output parameters */
+ ZERO_STRUCTP(domain_sid);
+ domain_name[0] = '\0';
+
switch (info_class) {
case 3:
diff --git a/source3/rpcclient/cmd_lsarpc.c b/source3/rpcclient/cmd_lsarpc.c
index 153d5366e0..f531fe9250 100644
--- a/source3/rpcclient/cmd_lsarpc.c
+++ b/source3/rpcclient/cmd_lsarpc.c
@@ -41,9 +41,8 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
return 0;
}
- if (!(mem_ctx=talloc_init()))
- {
- DEBUG(0,("cmd_lsa_query_info_poicy: talloc_init returned NULL!\n"));
+ if (!(mem_ctx = talloc_init())) {
+ DEBUG(0,("cmd_lsa_query_info_poicy: talloc_init failed\n"));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -53,7 +52,7 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
- fprintf (stderr, "Could not initialize samr pipe!\n");
+ DEBUG(0, ("Could not initialize samr pipe!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -75,7 +74,11 @@ static uint32 cmd_lsa_query_info_policy(struct cli_state *cli, int argc, char **
sid_to_string(sid_str, &dom_sid);
- printf("domain %s has sid %s\n", domain_name, sid_str);
+ if (domain_name[0]) {
+ printf("domain %s has sid %s\n", domain_name, sid_str);
+ } else {
+ printf("could not query info for level %d\n", info_class);
+ }
done:
@@ -106,15 +109,14 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
return 0;
}
- if (!(mem_ctx=talloc_init()))
- {
- DEBUG(0,("cmd_lsa_lookup_names: talloc_init returned NULL!\n"));
+ if (!(mem_ctx = talloc_init())) {
+ DEBUG(0,("cmd_lsa_lookup_names: talloc_init failed\n"));
return NT_STATUS_UNSUCCESSFUL;
}
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
- fprintf (stderr, "Could not initialize samr pipe!\n");
+ DEBUG(0, ("Could not initialize samr pipe!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -141,15 +143,10 @@ static uint32 cmd_lsa_lookup_names(struct cli_state *cli, int argc, char **argv)
fstring sid_str;
sid_to_string(sid_str, &sids[i]);
- printf("%s\t\t%s (%d)\n", argv[i + 1], sid_str,
+ printf("%s %s (%d)\n", argv[i + 1], sid_str,
types[i]);
}
-#if 0 /* JERRY */
- safe_free(sids);
- safe_free(types);
-#endif
-
done:
if (got_policy_hnd) {
@@ -180,15 +177,14 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
return 0;
}
- if (!(mem_ctx=talloc_init()))
- {
- DEBUG(0,("cmd_lsa_lookup_sids: talloc_init returned NULL!\n"));
+ if (!(mem_ctx = talloc_init())) {
+ DEBUG(0,("cmd_lsa_lookup_sids: talloc_init failed\n"));
return NT_STATUS_UNSUCCESSFUL;
}
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
- fprintf (stderr, "Could not initialize samr pipe!\n");
+ DEBUG(0, ("Could not initialize samr pipe!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -227,7 +223,7 @@ static uint32 cmd_lsa_lookup_sids(struct cli_state *cli, int argc, char **argv)
fstring sid_str;
sid_to_string(sid_str, &sids[i]);
- printf("%s\t\t%s (%d)\n", sid_str, names[i] ? names[i] :
+ printf("%s %s (%d)\n", sid_str, names[i] ? names[i] :
"*unknown*", types[i]);
}
@@ -273,15 +269,14 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
return 0;
}
- if (!(mem_ctx=talloc_init()))
- {
- DEBUG(0,("cmd_lsa_enum_trust_dom: talloc_init returned NULL!\n"));
+ if (!(mem_ctx = talloc_init())) {
+ DEBUG(0,("cmd_lsa_enum_trust_dom: talloc_init failed\n"));
return NT_STATUS_UNSUCCESSFUL;
}
/* Initialise RPC connection */
if (!cli_nt_session_open (cli, PIPE_LSARPC)) {
- fprintf (stderr, "Could not initialize samr pipe!\n");
+ DEBUG(0, ("Could not initialize samr pipe!\n"));
return NT_STATUS_UNSUCCESSFUL;
}
@@ -308,20 +303,10 @@ static uint32 cmd_lsa_enum_trust_dom(struct cli_state *cli, int argc, char **arg
fstring sid_str;
sid_to_string(sid_str, &domain_sids[i]);
- printf("%s\t\t%s\n", domain_names[i] ? domain_names[i] :
+ printf("%s %s\n", domain_names[i] ? domain_names[i] :
"*unknown*", sid_str);
}
-#if 0 /* JERRY */
- safe_free(domain_sids);
-
- for (i = 0; i < num_domains; i++) {
- safe_free(domain_names[i]);
- }
-
- safe_free(domain_names);
-#endif
-
done:
if (got_policy_hnd) {