diff options
Diffstat (limited to 'source/rpc_parse/parse_misc.c')
-rw-r--r-- | source/rpc_parse/parse_misc.c | 83 |
1 files changed, 23 insertions, 60 deletions
diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c index 3dd9c3bc2a3..466653af52c 100644 --- a/source/rpc_parse/parse_misc.c +++ b/source/rpc_parse/parse_misc.c @@ -1,5 +1,6 @@ /* - * Unix SMB/CIFS implementation. + * Unix SMB/Netbios implementation. + * Version 1.9. * RPC Pipe client / server routines * Copyright (C) Andrew Tridgell 1992-1997, * Copyright (C) Luke Kenneth Casson Leighton 1996-1997, @@ -14,16 +15,14 @@ * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + e * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include "includes.h" -#undef DBGC_CLASS -#define DBGC_CLASS DBGC_RPC_PARSE +#include "includes.h" /**************************************************************************** A temporary TALLOC context for things like unistrs, that is valid for @@ -63,7 +62,7 @@ void main_loop_talloc_free(void) TALLOC_CTX *main_loop_talloc_get(void) { if (!main_loop_talloc) { - main_loop_talloc = talloc_init_named("main loop talloc (mainly parse_misc)"); + main_loop_talloc = talloc_init(); if (!main_loop_talloc) smb_panic("main_loop_talloc: malloc fail\n"); } @@ -214,6 +213,9 @@ BOOL smb_io_dom_sid(char *desc, DOM_SID *sid, prs_struct *ps, int depth) prs_debug(ps, depth, desc, "smb_io_dom_sid"); depth++; + if(!prs_align(ps)) + return False; + if(!prs_uint8 ("sid_rev_num", ps, depth, &sid->sid_rev_num)) return False; if(!prs_uint8 ("num_auths ", ps, depth, &sid->num_auths)) @@ -535,7 +537,8 @@ void init_unistr(UNISTR *str, const char *buf) if (str->buffer == NULL) smb_panic("init_unistr: malloc fail\n"); - rpcstr_push(str->buffer, buf, len, STR_TERMINATE); + /* store the string (null-terminated copy) */ + dos_struni2((char *)str->buffer, buf, len); } /******************************************************************* @@ -566,7 +569,7 @@ static void create_buffer3(BUFFER3 *str, size_t len) if (len < MAX_BUFFERLEN) len = MAX_BUFFERLEN; - str->buffer = talloc_zero(get_talloc_ctx(), len); + str->buffer = talloc_zero(get_talloc_ctx(), len); if (str->buffer == NULL) smb_panic("create_buffer3: talloc fail\n"); @@ -598,12 +601,12 @@ void init_buffer3_str(BUFFER3 *str, char *buf, int len) /* set up string lengths. */ str->buf_max_len = len * 2; - str->buf_len = len * 2; + str->buf_len = len * 2; create_buffer3(str, str->buf_max_len); - rpcstr_push(str->buffer, buf, str->buf_max_len, STR_TERMINATE); - + /* store the string (null-terminated 8 bit chars into 16 bit chars) */ + dos_struni2((char *)str->buffer, buf, str->buf_max_len); } /******************************************************************* @@ -911,52 +914,8 @@ void init_unistr2(UNISTR2 *str, const char *buf, size_t len) if (buf==NULL) return; - rpcstr_push((char *)str->buffer, buf, len, STR_TERMINATE); -} - -/** - * Inits a UNISTR2 structure. - * @param ctx talloc context to allocate string on - * @param str pointer to string to create - * @param buf UCS2 null-terminated buffer to init from -*/ - -void init_unistr2_w(TALLOC_CTX *ctx, UNISTR2 *str, const smb_ucs2_t *buf) -{ - uint32 len = strlen_w(buf); - uint32 max_len = len; - uint32 alloc_len; - - ZERO_STRUCTP(str); - - /* set up string lengths. */ - str->uni_max_len = len; - str->undoc = 0; - str->uni_str_len = len; - - if (max_len < MAX_UNISTRLEN) - max_len = MAX_UNISTRLEN; - - alloc_len = (max_len + 1) * sizeof(uint16); - - str->buffer = (uint16 *)talloc_zero(ctx, alloc_len); - if ((str->buffer == NULL) && (alloc_len > 0)) - { - smb_panic("init_unistr2_w: malloc fail\n"); - return; - } - - /* - * don't move this test above ! The UNISTR2 must be initialized !!! - * jfm, 7/7/2001. - */ - if (buf==NULL) - return; - - /* Yes, this is a strncpy( foo, bar, strlen(bar)) - but as - long as the buffer above is talloc()ed correctly then this - is the correct thing to do */ - strncpy_w(str->buffer, buf, len + 1); + /* store the string (null-terminated 8 bit chars into 16 bit chars) */ + dos_struni2((char *)str->buffer, buf, len); } /******************************************************************* @@ -1197,8 +1156,8 @@ static BOOL smb_io_clnt_srv(char *desc, DOM_CLNT_SRV *log, prs_struct *ps, int d Inits a DOM_LOG_INFO structure. ********************************************************************/ -void init_log_info(DOM_LOG_INFO *log, const char *logon_srv, const char *acct_name, - uint16 sec_chan, const char *comp_name) +void init_log_info(DOM_LOG_INFO *log, char *logon_srv, char *acct_name, + uint16 sec_chan, char *comp_name) { DEBUG(5,("make_log_info %d\n", __LINE__)); @@ -1255,6 +1214,9 @@ BOOL smb_io_chal(char *desc, DOM_CHAL *chal, prs_struct *ps, int depth) prs_debug(ps, depth, desc, "smb_io_chal"); depth++; + + if(!prs_align(ps)) + return False; if(!prs_uint8s (False, "data", ps, depth, chal->data, 8)) return False; @@ -1525,7 +1487,8 @@ void init_unistr3(UNISTR3 *str, const char *buf) if (str->str.buffer == NULL) smb_panic("init_unistr3: malloc fail\n"); - rpcstr_push((char *)str->str.buffer, buf, len, STR_TERMINATE); + /* store the string (null-terminated copy) */ + dos_struni2((char *)str->str.buffer, buf, len); } /******************************************************************* |