diff options
Diffstat (limited to 'source3/rpc_parse')
-rw-r--r-- | source3/rpc_parse/parse_lsa.c | 8 | ||||
-rw-r--r-- | source3/rpc_parse/parse_misc.c | 84 | ||||
-rw-r--r-- | source3/rpc_parse/parse_ntsvcs.c | 4 | ||||
-rw-r--r-- | source3/rpc_parse/parse_spoolss.c | 10 | ||||
-rw-r--r-- | source3/rpc_parse/parse_svcctl.c | 2 |
5 files changed, 23 insertions, 85 deletions
diff --git a/source3/rpc_parse/parse_lsa.c b/source3/rpc_parse/parse_lsa.c index c6727d83b5..625ef5fb41 100644 --- a/source3/rpc_parse/parse_lsa.c +++ b/source3/rpc_parse/parse_lsa.c @@ -3222,13 +3222,13 @@ NTSTATUS init_r_enum_acct_rights( LSA_R_ENUM_ACCT_RIGHTS *out, PRIVILEGE_SET *pr for ( i=0; i<privileges->count; i++ ) { privname = luid_to_privilege_name( &privileges->set[i].luid ); if ( privname ) { - if ( !add_string_to_array( get_talloc_ctx(), privname, &privname_array, &num_priv ) ) + if ( !add_string_to_array( talloc_tos(), privname, &privname_array, &num_priv ) ) return NT_STATUS_NO_MEMORY; } } if ( num_priv ) { - out->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); + out->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY ); if (!out->rights) { return NT_STATUS_NO_MEMORY; } @@ -3299,7 +3299,7 @@ void init_q_add_acct_rights( LSA_Q_ADD_ACCT_RIGHTS *in, POLICY_HND *hnd, in->pol = *hnd; init_dom_sid2(&in->sid, sid); - in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); + in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY ); if (!in->rights) { smb_panic("init_q_add_acct_rights: talloc fail\n"); return; @@ -3367,7 +3367,7 @@ void init_q_remove_acct_rights(LSA_Q_REMOVE_ACCT_RIGHTS *in, in->removeall = removeall; in->count = count; - in->rights = TALLOC_P( get_talloc_ctx(), UNISTR4_ARRAY ); + in->rights = TALLOC_P( talloc_tos(), UNISTR4_ARRAY ); if (!in->rights) { smb_panic("init_q_remove_acct_rights: talloc fail\n"); return; diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index 15a71a11be..54d8ae4785 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -25,68 +25,6 @@ #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_PARSE -/**************************************************************************** - A temporary TALLOC context for things like unistrs, that is valid for - the life of a complete RPC call. -****************************************************************************/ - -static TALLOC_CTX *current_rpc_talloc = NULL; - -static TALLOC_CTX *get_current_rpc_talloc(void) -{ - return current_rpc_talloc; -} - -void set_current_rpc_talloc( TALLOC_CTX *ctx) -{ - current_rpc_talloc = ctx; -} - -static TALLOC_CTX *main_loop_talloc = NULL; - -/******************************************************************* -free up temporary memory - called from the main loop -********************************************************************/ - -void main_loop_TALLOC_FREE(void) -{ - if (!main_loop_talloc) - return; - talloc_destroy(main_loop_talloc); - main_loop_talloc = NULL; -} - -/******************************************************************* - Get a talloc context that is freed in the main loop... -********************************************************************/ - -TALLOC_CTX *main_loop_talloc_get(void) -{ - if (!main_loop_talloc) { - main_loop_talloc = talloc_init("main loop talloc (mainly parse_misc)"); - if (!main_loop_talloc) - smb_panic("main_loop_talloc: malloc fail"); - } - - return main_loop_talloc; -} - -/******************************************************************* - Try and get a talloc context. Get the rpc one if possible, else - get the main loop one. The main loop one is more dangerous as it - goes away between packets, the rpc one will stay around for as long - as a current RPC lasts. -********************************************************************/ - -TALLOC_CTX *get_talloc_ctx(void) -{ - TALLOC_CTX *tc = get_current_rpc_talloc(); - - if (tc) - return tc; - return main_loop_talloc_get(); -} - /******************************************************************* Reads or writes a UTIME type. ********************************************************************/ @@ -449,7 +387,7 @@ void init_unistr(UNISTR *str, const char *buf) len = strlen(buf) + 1; if (len) { - str->buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, len); + str->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, len); if (str->buffer == NULL) smb_panic("init_unistr: malloc fail"); @@ -485,7 +423,7 @@ BOOL smb_io_unistr(const char *desc, UNISTR *uni, prs_struct *ps, int depth) static void create_rpc_blob(RPC_DATA_BLOB *str, size_t len) { if (len) { - str->buffer = (uint8 *)TALLOC_ZERO(get_talloc_ctx(), len); + str->buffer = (uint8 *)TALLOC_ZERO(talloc_tos(), len); if (str->buffer == NULL) smb_panic("create_rpc_blob: talloc fail"); str->buf_len = len; @@ -591,7 +529,7 @@ void init_regval_buffer(REGVAL_BUFFER *str, const uint8 *buf, size_t len) if (buf != NULL) { SMB_ASSERT(str->buf_max_len >= str->buf_len); - str->buffer = (uint16 *)TALLOC_ZERO(get_talloc_ctx(), + str->buffer = (uint16 *)TALLOC_ZERO(talloc_tos(), str->buf_max_len); if (str->buffer == NULL) smb_panic("init_regval_buffer: talloc fail"); @@ -668,7 +606,7 @@ void copy_unistr2(UNISTR2 *str, const UNISTR2 *from) reallocation of memory. */ if (str->buffer == NULL) { if (str->uni_max_len) { - str->buffer = (uint16 *)TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, str->uni_max_len); + str->buffer = (uint16 *)TALLOC_ZERO_ARRAY(talloc_tos(), uint16, str->uni_max_len); if ((str->buffer == NULL)) { smb_panic("copy_unistr2: talloc fail"); return; @@ -701,7 +639,7 @@ void init_string2(STRING2 *str, const char *buf, size_t max_len, size_t str_len) /* store the string */ if(str_len != 0) { - str->buffer = (uint8 *)TALLOC_ZERO(get_talloc_ctx(), + str->buffer = (uint8 *)TALLOC_ZERO(talloc_tos(), str->str_max_len); if (str->buffer == NULL) smb_panic("init_string2: malloc fail"); @@ -778,7 +716,7 @@ void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) } - str->buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, len); + str->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, len); if (str->buffer == NULL) { smb_panic("init_unistr2: malloc fail"); return; @@ -814,7 +752,7 @@ void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags) { - uni4->string = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + uni4->string = TALLOC_P( talloc_tos(), UNISTR2 ); if (!uni4->string) { smb_panic("init_unistr4: talloc fail"); return; @@ -913,7 +851,7 @@ void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from) /* allocate the space and copy the string buffer */ if (i) { - to->buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, i); + to->buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, i); if (to->buffer == NULL) smb_panic("init_unistr2_from_unistr: malloc fail"); memcpy(to->buffer, from->buffer, i*sizeof(uint16)); @@ -1117,7 +1055,7 @@ BOOL prs_unistr4_array(const char *desc, prs_struct *ps, int depth, UNISTR4_ARRA if (UNMARSHALLING(ps)) { if (array->count) { - if ( !(array->strings = TALLOC_ZERO_ARRAY( get_talloc_ctx(), UNISTR4, array->count)) ) + if ( !(array->strings = TALLOC_ZERO_ARRAY( talloc_tos(), UNISTR4, array->count)) ) return False; } else { array->strings = NULL; @@ -1152,7 +1090,7 @@ BOOL init_unistr4_array( UNISTR4_ARRAY *array, uint32 count, const char **string /* allocate memory for the array of UNISTR4 objects */ if (array->count) { - if ( !(array->strings = TALLOC_ZERO_ARRAY(get_talloc_ctx(), UNISTR4, count )) ) + if ( !(array->strings = TALLOC_ZERO_ARRAY(talloc_tos(), UNISTR4, count )) ) return False; } else { array->strings = NULL; @@ -1707,7 +1645,7 @@ void init_unistr3(UNISTR3 *str, const char *buf) str->uni_str_len = strlen(buf) + 1; if (str->uni_str_len) { - str->str.buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, str->uni_str_len); + str->str.buffer = TALLOC_ZERO_ARRAY(talloc_tos(), uint16, str->uni_str_len); if (str->str.buffer == NULL) smb_panic("init_unistr3: malloc fail"); diff --git a/source3/rpc_parse/parse_ntsvcs.c b/source3/rpc_parse/parse_ntsvcs.c index 93061deb35..bcf3f55bd0 100644 --- a/source3/rpc_parse/parse_ntsvcs.c +++ b/source3/rpc_parse/parse_ntsvcs.c @@ -299,7 +299,7 @@ BOOL ntsvcs_io_q_get_hw_profile_info(const char *desc, NTSVCS_Q_GET_HW_PROFILE_I q_u->buffer_size = 0x000000a8; if ( UNMARSHALLING(ps) ) { - q_u->buffer = TALLOC_ARRAY(get_talloc_ctx(), uint8, q_u->buffer_size ); + q_u->buffer = TALLOC_ARRAY(talloc_tos(), uint8, q_u->buffer_size ); if (!q_u->buffer) { return False; } @@ -334,7 +334,7 @@ BOOL ntsvcs_io_r_get_hw_profile_info(const char *desc, NTSVCS_R_GET_HW_PROFILE_I if ( UNMARSHALLING(ps) ) { if (r_u->buffer_size) { - r_u->buffer = TALLOC_ARRAY(get_talloc_ctx(), uint8, r_u->buffer_size ); + r_u->buffer = TALLOC_ARRAY(talloc_tos(), uint8, r_u->buffer_size ); if (!r_u->buffer) { return False; } diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c index 99470c476c..a0d818bd67 100644 --- a/source3/rpc_parse/parse_spoolss.c +++ b/source3/rpc_parse/parse_spoolss.c @@ -905,7 +905,7 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, { DEBUG(5,("make_spoolss_q_open_printer_ex\n")); - q_u->printername = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + q_u->printername = TALLOC_P( talloc_tos(), UNISTR2 ); if (!q_u->printername) { return False; } @@ -921,7 +921,7 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, q_u->user_switch = 1; q_u->user_ctr.level = 1; - q_u->user_ctr.user.user1 = TALLOC_P( get_talloc_ctx(), SPOOL_USER_1 ); + q_u->user_ctr.user.user1 = TALLOC_P( talloc_tos(), SPOOL_USER_1 ); if (!q_u->user_ctr.user.user1) { return False; } @@ -931,11 +931,11 @@ BOOL make_spoolss_q_open_printer_ex(SPOOL_Q_OPEN_PRINTER_EX *q_u, q_u->user_ctr.user.user1->minor = 0; q_u->user_ctr.user.user1->processor = 0; - q_u->user_ctr.user.user1->client_name = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + q_u->user_ctr.user.user1->client_name = TALLOC_P( talloc_tos(), UNISTR2 ); if (!q_u->user_ctr.user.user1->client_name) { return False; } - q_u->user_ctr.user.user1->user_name = TALLOC_P( get_talloc_ctx(), UNISTR2 ); + q_u->user_ctr.user.user1->user_name = TALLOC_P( talloc_tos(), UNISTR2 ); if (!q_u->user_ctr.user.user1->user_name) { return False; } @@ -986,7 +986,7 @@ BOOL make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u q_u->user_switch=1; q_u->user_ctr.level = 1; - q_u->user_ctr.user.user1 = TALLOC_P( get_talloc_ctx(), SPOOL_USER_1 ); + q_u->user_ctr.user.user1 = TALLOC_P( talloc_tos(), SPOOL_USER_1 ); if (!q_u->user_ctr.user.user1) { return False; } diff --git a/source3/rpc_parse/parse_svcctl.c b/source3/rpc_parse/parse_svcctl.c index b366b14e7f..b571034d4c 100644 --- a/source3/rpc_parse/parse_svcctl.c +++ b/source3/rpc_parse/parse_svcctl.c @@ -783,7 +783,7 @@ BOOL svcctl_io_service_fa( const char *desc, SERVICE_FAILURE_ACTIONS *fa, RPC_BU if ( UNMARSHALLING(ps)) { if (fa->num_actions) { - if ( !(fa->actions = TALLOC_ARRAY( get_talloc_ctx(), SC_ACTION, fa->num_actions )) ) { + if ( !(fa->actions = TALLOC_ARRAY( talloc_tos(), SC_ACTION, fa->num_actions )) ) { DEBUG(0,("svcctl_io_service_fa: talloc() failure!\n")); return False; } |