mirror of
https://github.com/samba-team/samba.git
synced 2025-11-26 04:23:49 +03:00
Make use of talloc_pool in the main codepaths. Remove the sub-contexts.
Jeremy.
This commit is contained in:
@@ -1604,7 +1604,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
SEC_DESC *psd = NULL;
|
||||
size_t sd_size;
|
||||
uint32 security_info_wanted;
|
||||
TALLOC_CTX *frame;
|
||||
files_struct *fsp = NULL;
|
||||
NTSTATUS status;
|
||||
DATA_BLOB blob;
|
||||
@@ -1631,8 +1630,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
return;
|
||||
}
|
||||
|
||||
frame = talloc_stackframe();
|
||||
|
||||
/*
|
||||
* Get the permissions to return.
|
||||
*/
|
||||
@@ -1651,7 +1648,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
}
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(frame);
|
||||
reply_nterror(req, status);
|
||||
return;
|
||||
}
|
||||
@@ -1665,7 +1661,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
if (max_data_count < sd_size) {
|
||||
send_nt_replies(conn, req, NT_STATUS_BUFFER_TOO_SMALL,
|
||||
params, 4, *ppdata, 0);
|
||||
TALLOC_FREE(frame);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1675,7 +1670,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
|
||||
data = nttrans_realloc(ppdata, sd_size);
|
||||
if(data == NULL) {
|
||||
TALLOC_FREE(frame);
|
||||
reply_doserror(req, ERRDOS, ERRnomem);
|
||||
return;
|
||||
}
|
||||
@@ -1684,7 +1678,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
&blob.data, &blob.length);
|
||||
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
TALLOC_FREE(frame);
|
||||
reply_nterror(req, status);
|
||||
return;
|
||||
}
|
||||
@@ -1694,7 +1687,6 @@ static void call_nt_transact_query_security_desc(connection_struct *conn,
|
||||
|
||||
send_nt_replies(conn, req, NT_STATUS_OK, params, 4, data, (int)sd_size);
|
||||
|
||||
TALLOC_FREE(frame);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
|
||||
char *saved_dir = NULL;
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
SMB_STRUCT_STAT parent_st;
|
||||
TALLOC_CTX *ctx = talloc_stackframe();
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
NTSTATUS status = NT_STATUS_OK;
|
||||
int ret;
|
||||
|
||||
@@ -135,7 +135,6 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
|
||||
DEBUG(0,("change_dir_owner_to_parent: failed to stat parent "
|
||||
"directory %s. Error was %s\n",
|
||||
inherit_from_dir, strerror(errno) ));
|
||||
TALLOC_FREE(ctx);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -152,7 +151,6 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
|
||||
DEBUG(0,("change_dir_owner_to_parent: failed to get "
|
||||
"current working directory. Error was %s\n",
|
||||
strerror(errno)));
|
||||
TALLOC_FREE(ctx);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -202,7 +200,6 @@ static NTSTATUS change_dir_owner_to_parent(connection_struct *conn,
|
||||
|
||||
out:
|
||||
|
||||
TALLOC_FREE(ctx);
|
||||
vfs_ChDir(conn,saved_dir);
|
||||
return status;
|
||||
}
|
||||
@@ -2707,7 +2704,6 @@ NTSTATUS create_file(connection_struct *conn,
|
||||
int *pinfo,
|
||||
SMB_STRUCT_STAT *psbuf)
|
||||
{
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
struct case_semantics_state *case_state = NULL;
|
||||
SMB_STRUCT_STAT sbuf;
|
||||
int info = FILE_WAS_OPENED;
|
||||
@@ -2918,7 +2914,6 @@ NTSTATUS create_file(connection_struct *conn,
|
||||
if (psbuf != NULL) {
|
||||
*psbuf = sbuf;
|
||||
}
|
||||
TALLOC_FREE(frame);
|
||||
return NT_STATUS_OK;
|
||||
|
||||
fail:
|
||||
@@ -2928,6 +2923,5 @@ NTSTATUS create_file(connection_struct *conn,
|
||||
close_file(fsp, ERROR_CLOSE);
|
||||
fsp = NULL;
|
||||
}
|
||||
TALLOC_FREE(frame);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -2071,7 +2071,7 @@ void smbd_process(void)
|
||||
char *inbuf;
|
||||
size_t inbuf_len;
|
||||
bool encrypted = false;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
TALLOC_CTX *frame = talloc_stackframe_pool(8192);
|
||||
|
||||
errno = 0;
|
||||
|
||||
|
||||
@@ -357,7 +357,6 @@ void load_registry_shares(void)
|
||||
int find_service(fstring service)
|
||||
{
|
||||
int iService;
|
||||
TALLOC_CTX *frame = talloc_stackframe();
|
||||
|
||||
all_string_sub(service,"\\","/",0);
|
||||
|
||||
@@ -463,8 +462,6 @@ int find_service(fstring service)
|
||||
if (iService < 0)
|
||||
DEBUG(3,("find_service() failed to find service %s\n", service));
|
||||
|
||||
TALLOC_FREE(frame);
|
||||
|
||||
return (iService);
|
||||
}
|
||||
|
||||
@@ -1150,20 +1147,17 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
|
||||
#if SOFTLINK_OPTIMISATION
|
||||
/* resolve any soft links early if possible */
|
||||
if (vfs_ChDir(conn,conn->connectpath) == 0) {
|
||||
TALLOC_CTX *ctx = talloc_stackframe();
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
char *s = vfs_GetWd(ctx,s);
|
||||
if (!s) {
|
||||
*status = map_nt_error_from_unix(errno);
|
||||
TALLOC_FREE(ctx);
|
||||
goto err_root_exit;
|
||||
}
|
||||
if (!set_conn_connectpath(conn,s)) {
|
||||
*status = NT_STATUS_NO_MEMORY;
|
||||
TALLOC_FREE(ctx);
|
||||
goto err_root_exit;
|
||||
}
|
||||
vfs_ChDir(conn,conn->connectpath);
|
||||
TALLOC_FREE(ctx);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -297,9 +297,8 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
|
||||
if (!lp_ea_support(SNUM(conn))) {
|
||||
return 0;
|
||||
}
|
||||
mem_ctx = talloc_init("estimate_ea_size");
|
||||
mem_ctx = talloc_tos();
|
||||
(void)get_ea_list_from_file(mem_ctx, conn, fsp, fname, &total_ea_len);
|
||||
talloc_destroy(mem_ctx);
|
||||
return total_ea_len;
|
||||
}
|
||||
|
||||
@@ -310,7 +309,7 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp,
|
||||
static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, const char *fname, fstring unix_ea_name)
|
||||
{
|
||||
size_t total_ea_len;
|
||||
TALLOC_CTX *mem_ctx = talloc_init("canonicalize_ea_name");
|
||||
TALLOC_CTX *mem_ctx = talloc_tos();
|
||||
struct ea_list *ea_list = get_ea_list_from_file(mem_ctx, conn, fsp, fname, &total_ea_len);
|
||||
|
||||
for (; ea_list; ea_list = ea_list->next) {
|
||||
@@ -321,7 +320,6 @@ static void canonicalize_ea_name(connection_struct *conn, files_struct *fsp, con
|
||||
break;
|
||||
}
|
||||
}
|
||||
talloc_destroy(mem_ctx);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -1955,9 +1953,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
|
||||
out_of_space = True;
|
||||
finished = False;
|
||||
} else {
|
||||
TALLOC_CTX *sub_ctx = talloc_stackframe();
|
||||
|
||||
finished = !get_lanman2_dir_entry(sub_ctx,
|
||||
finished = !get_lanman2_dir_entry(ctx,
|
||||
conn,
|
||||
req->flags2,
|
||||
mask,dirtype,info_level,
|
||||
@@ -1966,8 +1962,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
|
||||
space_remaining, &out_of_space,
|
||||
&got_exact_match,
|
||||
&last_entry_off, ea_list);
|
||||
|
||||
TALLOC_FREE(sub_ctx);
|
||||
}
|
||||
|
||||
if (finished && out_of_space)
|
||||
@@ -2303,9 +2297,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
|
||||
out_of_space = True;
|
||||
finished = False;
|
||||
} else {
|
||||
TALLOC_CTX *sub_ctx = talloc_stackframe();
|
||||
|
||||
finished = !get_lanman2_dir_entry(sub_ctx,
|
||||
finished = !get_lanman2_dir_entry(ctx,
|
||||
conn,
|
||||
req->flags2,
|
||||
mask,dirtype,info_level,
|
||||
@@ -2314,8 +2306,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
|
||||
space_remaining, &out_of_space,
|
||||
&got_exact_match,
|
||||
&last_entry_off, ea_list);
|
||||
|
||||
TALLOC_FREE(sub_ctx);
|
||||
}
|
||||
|
||||
if (finished && out_of_space)
|
||||
@@ -4759,17 +4749,12 @@ static NTSTATUS smb_info_set_ea(connection_struct *conn,
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
ctx = talloc_init("SMB_INFO_SET_EA");
|
||||
if (!ctx) {
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
ctx = talloc_tos();
|
||||
ea_list = read_ea_list(ctx, pdata + 4, total_data - 4);
|
||||
if (!ea_list) {
|
||||
talloc_destroy(ctx);
|
||||
return NT_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
status = set_ea(conn, fsp, fname, ea_list);
|
||||
talloc_destroy(ctx);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -869,14 +869,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
|
||||
return map_nt_error_from_unix(errno);
|
||||
case ENOENT:
|
||||
{
|
||||
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
||||
TALLOC_CTX *ctx = talloc_tos();
|
||||
char *tmp_fname = NULL;
|
||||
char *last_component = NULL;
|
||||
/* Last component didn't exist. Remove it and try and canonicalise the directory. */
|
||||
|
||||
tmp_fname = talloc_strdup(tmp_ctx, fname);
|
||||
tmp_fname = talloc_strdup(ctx, fname);
|
||||
if (!tmp_fname) {
|
||||
TALLOC_FREE(tmp_ctx);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
p = strrchr_m(tmp_fname, '/');
|
||||
@@ -885,10 +884,9 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
|
||||
last_component = p;
|
||||
} else {
|
||||
last_component = tmp_fname;
|
||||
tmp_fname = talloc_strdup(tmp_ctx,
|
||||
tmp_fname = talloc_strdup(ctx,
|
||||
".");
|
||||
if (!tmp_fname) {
|
||||
TALLOC_FREE(tmp_ctx);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
@@ -900,15 +898,13 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
|
||||
#endif
|
||||
if (!resolved_name) {
|
||||
DEBUG(3,("reduce_name: couldn't get realpath for %s\n", fname));
|
||||
TALLOC_FREE(tmp_ctx);
|
||||
return map_nt_error_from_unix(errno);
|
||||
}
|
||||
tmp_fname = talloc_asprintf(tmp_ctx,
|
||||
tmp_fname = talloc_asprintf(ctx,
|
||||
"%s/%s",
|
||||
resolved_name,
|
||||
last_component);
|
||||
if (!tmp_fname) {
|
||||
TALLOC_FREE(tmp_ctx);
|
||||
return NT_STATUS_NO_MEMORY;
|
||||
}
|
||||
#ifdef REALPATH_TAKES_NULL
|
||||
@@ -922,7 +918,6 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
|
||||
safe_strcpy(resolved_name_buf, tmp_fname, PATH_MAX);
|
||||
resolved_name = resolved_name_buf;
|
||||
#endif
|
||||
TALLOC_FREE(tmp_ctx);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user