From a3aa2c9ed44f5967986d340456efd5828bd5f2ff Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 7 Nov 2003 18:32:29 +0000 Subject: Handle munged dial string. Patch from Aur?lien Degr?mont with memory leak fixes by me. Jeremy. (This used to be commit daceed37387c517b3f0ab9c173f419215e3d676b) --- source3/rpc_parse/parse_misc.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'source3/rpc_parse/parse_misc.c') diff --git a/source3/rpc_parse/parse_misc.c b/source3/rpc_parse/parse_misc.c index a075dbd833..b0144c2c89 100644 --- a/source3/rpc_parse/parse_misc.c +++ b/source3/rpc_parse/parse_misc.c @@ -1028,6 +1028,27 @@ void init_unistr2_from_unistr(UNISTR2 *to, const UNISTR *from) return; } +/******************************************************************* + Inits a UNISTR2 structure from a DATA_BLOB. + The length of the data_blob must count the bytes of the buffer. + Copies the blob data. +********************************************************************/ + +void init_unistr2_from_datablob(UNISTR2 *str, DATA_BLOB *blob) +{ + /* Allocs the unistring */ + init_unistr2(str, NULL, UNI_FLAGS_NONE); + + /* Sets the values */ + str->uni_str_len = blob->length / sizeof(uint16); + str->uni_max_len = str->uni_str_len; + str->offset = 0; + str->buffer = (uint16 *) memdup(blob->data, blob->length); + if (!str->buffer) { + smb_panic("init_unistr2_from_datablob: malloc fail\n"); + } +} + /******************************************************************* Reads or writes a UNISTR2 structure. XXXX NOTE: UNISTR2 structures need NOT be null-terminated. -- cgit