From c8ade07760ae0ccfdf2d875c9f3027926e62321b Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 10 Oct 2012 11:50:27 +1100 Subject: smbd: Add mem_ctx to {f,}get_nt_acl VFS call This makes it clear which context the returned SD is allocated on, as a number of callers do not want it on talloc_tos(). As the ACL transformation allocates and then no longer needs a great deal of memory, a talloc_stackframe() call is used to contain the memory that is not returned further up the stack. Andrew Bartlett --- source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c index 982b0b479b..0249ef5661 100644 --- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c @@ -2185,15 +2185,22 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p, goto error_exit; } + sd_buf = talloc_zero(p->mem_ctx, struct sec_desc_buf); + if (!sd_buf) { + werr = WERR_NOMEM; + goto error_exit; + } + nt_status = SMB_VFS_FGET_NT_ACL(fsp, (SECINFO_OWNER |SECINFO_GROUP - |SECINFO_DACL), &psd); + |SECINFO_DACL), sd_buf, &sd_buf->sd); if (!NT_STATUS_IS_OK(nt_status)) { DEBUG(3,("_srvsvc_NetGetFileSecurity: Unable to get NT ACL " "for file %s\n", smb_fname_str_dbg(smb_fname))); werr = ntstatus_to_werror(nt_status); + TALLOC_FREE(sd_buf); goto error_exit; } @@ -2203,14 +2210,7 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p, sd_size = ndr_size_security_descriptor(psd, 0); - sd_buf = talloc_zero(p->mem_ctx, struct sec_desc_buf); - if (!sd_buf) { - werr = WERR_NOMEM; - goto error_exit; - } - sd_buf->sd_size = sd_size; - sd_buf->sd = talloc_move(p->mem_ctx, &psd); *r->out.sd_buf = sd_buf; -- cgit