diff options
author | Jeremy Allison <jra@samba.org> | 2001-05-01 23:07:30 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2001-05-01 23:07:30 +0000 |
commit | 0ae0d024f5898f7e47e4b1d4487b15447096780c (patch) | |
tree | b595006c08c2f2c20bca62a1a1ccf7bc69138b62 | |
parent | 52a9226a5aaa769e960619c2bd0a561dd9b0493d (diff) | |
download | samba-0ae0d024f5898f7e47e4b1d4487b15447096780c.tar.gz samba-0ae0d024f5898f7e47e4b1d4487b15447096780c.tar.xz samba-0ae0d024f5898f7e47e4b1d4487b15447096780c.zip |
Fixup smbcacls. Don't return memory already freed, don't free memory allocated
with talloc.
Jeremy.
-rw-r--r-- | source/include/proto.h | 2 | ||||
-rw-r--r-- | source/libsmb/clisecdesc.c | 13 | ||||
-rw-r--r-- | source/utils/smbcacls.c | 13 |
3 files changed, 5 insertions, 23 deletions
diff --git a/source/include/proto.h b/source/include/proto.h index 35d2793e9b1..d231ca06e4b 100644 --- a/source/include/proto.h +++ b/source/include/proto.h @@ -1127,7 +1127,7 @@ ssize_t cli_smbwrite(struct cli_state *cli, /*The following definitions come from libsmb/clisecdesc.c */ -SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd); +SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd, TALLOC_CTX *mem_ctx); BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd); /*The following definitions come from libsmb/clistr.c */ diff --git a/source/libsmb/clisecdesc.c b/source/libsmb/clisecdesc.c index 6824a0edf44..69c7d5f73fd 100644 --- a/source/libsmb/clisecdesc.c +++ b/source/libsmb/clisecdesc.c @@ -28,12 +28,11 @@ /**************************************************************************** query the security descriptor for a open file ****************************************************************************/ -SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd) +SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd, TALLOC_CTX *mem_ctx) { char param[8]; char *rparam=NULL, *rdata=NULL; int rparam_count=0, rdata_count=0; - TALLOC_CTX *mem_ctx=NULL; prs_struct pd; SEC_DESC *psd = NULL; @@ -58,11 +57,6 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd) goto cleanup; } - if ((mem_ctx = talloc_init()) == NULL) { - DEBUG(0,("talloc_init failed.\n")); - goto cleanup; - } - prs_init(&pd, rdata_count, mem_ctx, UNMARSHALL); prs_append_data(&pd, rdata, rdata_count); pd.data_offset = 0; @@ -74,7 +68,6 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd) cleanup: - talloc_destroy(mem_ctx); safe_free(rparam); safe_free(rdata); @@ -82,9 +75,6 @@ SEC_DESC *cli_query_secdesc(struct cli_state *cli,int fd) return psd; } - - - /**************************************************************************** set the security descriptor for a open file ****************************************************************************/ @@ -143,4 +133,3 @@ BOOL cli_set_secdesc(struct cli_state *cli,int fd, SEC_DESC *sd) prs_mem_free(&pd); return ret; } - diff --git a/source/utils/smbcacls.c b/source/utils/smbcacls.c index 66b15ea1acc..7b459a32ed6 100644 --- a/source/utils/smbcacls.c +++ b/source/utils/smbcacls.c @@ -127,10 +127,6 @@ static void SidToString(fstring str, DOM_SID *sid) /* Converted OK */ fstrcpy(str, names[0]); - - safe_free(names[0]); - safe_free(names); - safe_free(types); } /* convert a string to a SID, either numeric or username/group */ @@ -154,9 +150,6 @@ static BOOL StringToSid(DOM_SID *sid, char *str) sid_copy(sid, &sids[0]); - safe_free(sids); - safe_free(types); - done: return result; @@ -458,7 +451,7 @@ static int cacl_dump(struct cli_state *cli, char *filename) return EXIT_FAILED; } - sd = cli_query_secdesc(cli, fnum); + sd = cli_query_secdesc(cli, fnum, ctx); if (!sd) { printf("ERROR: secdesc query failed: %s\n", cli_errstr(cli)); @@ -495,7 +488,7 @@ static int owner_set(struct cli_state *cli, enum chown_mode change_mode, if (!StringToSid(&sid, new_username)) return EXIT_PARSE_ERROR; - old = cli_query_secdesc(cli, fnum); + old = cli_query_secdesc(cli, fnum, ctx); cli_close(cli, fnum); @@ -589,7 +582,7 @@ static int cacl_set(struct cli_state *cli, char *filename, return EXIT_FAILED; } - old = cli_query_secdesc(cli, fnum); + old = cli_query_secdesc(cli, fnum, ctx); if (!old) { printf("calc_set: Failed to query old descriptor\n"); |