#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.
********************************************************************/
if(!prs_align(ps))
return False;
-
+
if (MARSHALLING(ps)) {
low = *nttime & 0xFFFFFFFF;
high = *nttime >> 32;
return smb_io_time( desc, nttime, ps, depth );
}
+/*******************************************************************
+ Gets an enumeration handle from an ENUM_HND structure.
+********************************************************************/
+
+uint32 get_enum_hnd(ENUM_HND *enh)
+{
+ return (enh && enh->ptr_hnd != 0) ? enh->handle : 0;
+}
+
+/*******************************************************************
+ Inits an ENUM_HND structure.
+********************************************************************/
+
+void init_enum_hnd(ENUM_HND *enh, uint32 hnd)
+{
+ DEBUG(5,("smb_io_enum_hnd\n"));
+
+ enh->ptr_hnd = (hnd != 0) ? 1 : 0;
+ enh->handle = hnd;
+}
+
+/*******************************************************************
+ Reads or writes an ENUM_HND structure.
+********************************************************************/
+
+BOOL smb_io_enum_hnd(const char *desc, ENUM_HND *hnd, prs_struct *ps, int depth)
+{
+ if (hnd == NULL)
+ return False;
+
+ prs_debug(ps, depth, desc, "smb_io_enum_hnd");
+ depth++;
+
+ if(!prs_align(ps))
+ return False;
+
+ if(!prs_uint32("ptr_hnd", ps, depth, &hnd->ptr_hnd)) /* pointer */
+ return False;
+
+ if (hnd->ptr_hnd != 0) {
+ if(!prs_uint32("handle ", ps, depth, &hnd->handle )) /* enum handle */
+ return False;
+ }
+
+ return True;
+}
+
/*******************************************************************
Reads or writes a DOM_SID structure.
********************************************************************/
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");
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;
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");
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;
/* 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");
}
- 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;
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;
/* 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));
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;
/* 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;
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");