diff options
Diffstat (limited to 'source/rpc_parse/parse_misc.c')
-rw-r--r-- | source/rpc_parse/parse_misc.c | 78 |
1 files changed, 62 insertions, 16 deletions
diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c index 848fdae5e0e..9fa7c7d674d 100644 --- a/source/rpc_parse/parse_misc.c +++ b/source/rpc_parse/parse_misc.c @@ -66,7 +66,7 @@ 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"); + smb_panic("main_loop_talloc: malloc fail\n"); } return main_loop_talloc; @@ -124,7 +124,7 @@ BOOL smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth) if(!prs_align(ps)) return False; - + if (MARSHALLING(ps)) { low = *nttime & 0xFFFFFFFF; high = *nttime >> 32; @@ -152,6 +152,53 @@ BOOL smb_io_nttime(const char *desc, prs_struct *ps, int depth, NTTIME *nttime) } /******************************************************************* + 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. ********************************************************************/ @@ -452,7 +499,7 @@ void init_unistr(UNISTR *str, const char *buf) if (len) { str->buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, len); if (str->buffer == NULL) - smb_panic("init_unistr: malloc fail"); + smb_panic("init_unistr: malloc fail\n"); rpcstr_push(str->buffer, buf, len*sizeof(uint16), STR_TERMINATE); } else { @@ -488,7 +535,7 @@ static void create_rpc_blob(RPC_DATA_BLOB *str, size_t len) if (len) { str->buffer = (uint8 *)TALLOC_ZERO(get_talloc_ctx(), len); if (str->buffer == NULL) - smb_panic("create_rpc_blob: talloc fail"); + smb_panic("create_rpc_blob: talloc fail\n"); str->buf_len = len; } else { str->buffer = NULL; @@ -595,7 +642,7 @@ void init_regval_buffer(REGVAL_BUFFER *str, const uint8 *buf, size_t len) str->buffer = (uint16 *)TALLOC_ZERO(get_talloc_ctx(), str->buf_max_len); if (str->buffer == NULL) - smb_panic("init_regval_buffer: talloc fail"); + smb_panic("init_regval_buffer: talloc fail\n"); memcpy(str->buffer, buf, str->buf_len); } } @@ -671,7 +718,7 @@ void copy_unistr2(UNISTR2 *str, const UNISTR2 *from) if (str->uni_max_len) { str->buffer = (uint16 *)TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, str->uni_max_len); if ((str->buffer == NULL)) { - smb_panic("copy_unistr2: talloc fail"); + smb_panic("copy_unistr2: talloc fail\n"); return; } /* copy the string */ @@ -705,7 +752,7 @@ void init_string2(STRING2 *str, const char *buf, size_t max_len, size_t str_len) str->buffer = (uint8 *)TALLOC_ZERO(get_talloc_ctx(), str->str_max_len); if (str->buffer == NULL) - smb_panic("init_string2: malloc fail"); + smb_panic("init_string2: malloc fail\n"); memcpy(str->buffer, buf, str_len); } } @@ -781,7 +828,7 @@ void init_unistr2(UNISTR2 *str, const char *buf, enum unistr2_term_codes flags) str->buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, len); if (str->buffer == NULL) { - smb_panic("init_unistr2: malloc fail"); + smb_panic("init_unistr2: malloc fail\n"); return; } @@ -817,7 +864,7 @@ void init_unistr4(UNISTR4 *uni4, const char *buf, enum unistr2_term_codes flags) { uni4->string = TALLOC_P( get_talloc_ctx(), UNISTR2 ); if (!uni4->string) { - smb_panic("init_unistr4: talloc fail"); + smb_panic("init_unistr4: talloc fail\n"); return; } init_unistr2( uni4->string, buf, flags ); @@ -830,7 +877,7 @@ void init_unistr4_w( TALLOC_CTX *ctx, UNISTR4 *uni4, const smb_ucs2_t *buf ) { uni4->string = TALLOC_P( ctx, UNISTR2 ); if (!uni4->string) { - smb_panic("init_unistr4_w: talloc fail"); + smb_panic("init_unistr4_w: talloc fail\n"); return; } init_unistr2_w( ctx, uni4->string, buf ); @@ -860,7 +907,7 @@ void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf) if (len + 1) { str->buffer = TALLOC_ZERO_ARRAY(ctx, uint16, len + 1); if (str->buffer == NULL) { - smb_panic("init_unistr2_w: talloc fail"); + smb_panic("init_unistr2_w: talloc fail\n"); return; } } else { @@ -916,7 +963,7 @@ void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from) if (i) { to->buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, i); if (to->buffer == NULL) - smb_panic("init_unistr2_from_unistr: malloc fail"); + smb_panic("init_unistr2_from_unistr: malloc fail\n"); memcpy(to->buffer, from->buffer, i*sizeof(uint16)); } else { to->buffer = NULL; @@ -945,7 +992,7 @@ void init_unistr2_from_datablob(UNISTR2 *str, DATA_BLOB *blob) str->buffer = NULL; } if ((str->buffer == NULL) && (blob->length > 0)) { - smb_panic("init_unistr2_from_datablob: malloc fail"); + smb_panic("init_unistr2_from_datablob: malloc fail\n"); } } @@ -1337,8 +1384,7 @@ void init_dom_rid4(DOM_RID4 *rid4, uint16 unknown, uint16 attr, uint32 rid) Inits a DOM_CLNT_SRV structure. ********************************************************************/ -void init_clnt_srv(DOM_CLNT_SRV *logcln, const char *logon_srv, - const char *comp_name) +static void init_clnt_srv(DOM_CLNT_SRV *logcln, const char *logon_srv, const char *comp_name) { DEBUG(5,("init_clnt_srv: %d\n", __LINE__)); @@ -1710,7 +1756,7 @@ void init_unistr3(UNISTR3 *str, const char *buf) if (str->uni_str_len) { str->str.buffer = TALLOC_ZERO_ARRAY(get_talloc_ctx(), uint16, str->uni_str_len); if (str->str.buffer == NULL) - smb_panic("init_unistr3: malloc fail"); + smb_panic("init_unistr3: malloc fail\n"); rpcstr_push((char *)str->str.buffer, buf, str->uni_str_len * sizeof(uint16), STR_TERMINATE); } else { |