From 02fe7ce260617fa9bf0ed2eaa70c9aed11a8aa60 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 9 May 2007 16:26:43 +0000 Subject: r22770: sync with SAMBA_3_0_25 as of svn r22765 --- source/rpc_parse/parse_misc.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) (limited to 'source/rpc_parse') diff --git a/source/rpc_parse/parse_misc.c b/source/rpc_parse/parse_misc.c index a926a5e18ee..9fa7c7d674d 100644 --- a/source/rpc_parse/parse_misc.c +++ b/source/rpc_parse/parse_misc.c @@ -530,12 +530,17 @@ BOOL smb_io_unistr(const char *desc, UNISTR *uni, prs_struct *ps, int depth) Allocate the RPC_DATA_BLOB memory. ********************************************************************/ -size_t create_rpc_blob(RPC_DATA_BLOB *str, size_t len) +static void create_rpc_blob(RPC_DATA_BLOB *str, size_t len) { - str->buffer = (uint8 *)TALLOC_ZERO(get_talloc_ctx(), len); - if (str->buffer == NULL) - smb_panic("create_rpc_blob: talloc fail\n"); - return len; + if (len) { + str->buffer = (uint8 *)TALLOC_ZERO(get_talloc_ctx(), len); + if (str->buffer == NULL) + smb_panic("create_rpc_blob: talloc fail\n"); + str->buf_len = len; + } else { + str->buffer = NULL; + str->buf_len = 0; + } } /******************************************************************* @@ -547,7 +552,7 @@ void init_rpc_blob_uint32(RPC_DATA_BLOB *str, uint32 val) ZERO_STRUCTP(str); /* set up string lengths. */ - str->buf_len = create_rpc_blob(str, sizeof(uint32)); + create_rpc_blob(str, sizeof(uint32)); SIVAL(str->buffer, 0, val); } @@ -560,9 +565,10 @@ void init_rpc_blob_str(RPC_DATA_BLOB *str, const char *buf, int len) ZERO_STRUCTP(str); /* set up string lengths. */ - str->buf_len = create_rpc_blob(str, len*2); - rpcstr_push(str->buffer, buf, (size_t)str->buf_len, STR_TERMINATE); - + if (len) { + create_rpc_blob(str, len*2); + rpcstr_push(str->buffer, buf, (size_t)str->buf_len, STR_TERMINATE); + } } /******************************************************************* @@ -572,8 +578,10 @@ void init_rpc_blob_str(RPC_DATA_BLOB *str, const char *buf, int len) void init_rpc_blob_hex(RPC_DATA_BLOB *str, const char *buf) { ZERO_STRUCTP(str); - str->buf_len = create_rpc_blob(str, strlen(buf)); - str->buf_len = strhex_to_str((char *)str->buffer, str->buf_len, buf); + if (buf && *buf) { + create_rpc_blob(str, strlen(buf)); + str->buf_len = strhex_to_str((char *)str->buffer, str->buf_len, buf); + } } /******************************************************************* @@ -585,8 +593,8 @@ void init_rpc_blob_bytes(RPC_DATA_BLOB *str, uint8 *buf, size_t len) ZERO_STRUCTP(str); /* max buffer size (allocated size) */ - if (buf != NULL) { - len = create_rpc_blob(str, len); + if (buf != NULL && len) { + create_rpc_blob(str, len); memcpy(str->buffer, buf, len); } str->buf_len = len; -- cgit