forked from osmocom/wireshark
Get rid of tvb_get_faked_unicode() - tvb_get_string_enc() does the job
better. We don't need eventlog_get_unicode_string_length() in the eventlog dissector, either - tvb_unicode_strsize() does the job just as well. svn path=/trunk/; revision=54874
This commit is contained in:
parent
35d0d0f1ae
commit
4d9475e4ef
|
@ -344,39 +344,25 @@ eventlog_dissect_element_Record_sid_offset(tvbuff_t *tvb, int offset, packet_inf
|
|||
return offset;
|
||||
}
|
||||
static int
|
||||
eventlog_get_unicode_string_length(tvbuff_t *tvb, int offset)
|
||||
{
|
||||
int len;
|
||||
len=0;
|
||||
while(1){
|
||||
if(!tvb_get_ntohs(tvb, offset+len*2)){
|
||||
len++;
|
||||
break;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
static int
|
||||
eventlog_dissect_element_Record_source_name(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, dcerpc_info *di _U_, guint8 *drep _U_)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
len=eventlog_get_unicode_string_length(tvb, offset);
|
||||
str=tvb_get_faked_unicode(wmem_packet_scope(), tvb, offset, len, TRUE);
|
||||
proto_tree_add_string_format(tree, hf_eventlog_Record_source_name, tvb, offset, len*2, str, "source_name: %s", str);
|
||||
offset+=len*2;
|
||||
guint len;
|
||||
|
||||
len=tvb_unicode_strsize(tvb, offset);
|
||||
proto_tree_add_item(tree, hf_eventlog_Record_source_name, tvb, offset, len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
|
||||
|
||||
offset+=len;
|
||||
return offset;
|
||||
}
|
||||
static int
|
||||
eventlog_dissect_element_Record_computer_name(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, dcerpc_info *di _U_, guint8 *drep _U_)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
len=eventlog_get_unicode_string_length(tvb, offset);
|
||||
str=tvb_get_faked_unicode(wmem_packet_scope(), tvb, offset, len, TRUE);
|
||||
proto_tree_add_string_format(tree, hf_eventlog_Record_computer_name, tvb, offset, len*2, str, "computer_name: %s", str);
|
||||
offset+=len*2;
|
||||
guint len;
|
||||
|
||||
len=tvb_unicode_strsize(tvb, offset);
|
||||
proto_tree_add_item(tree, hf_eventlog_Record_computer_name, tvb, offset, len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
|
||||
|
||||
offset+=len;
|
||||
return offset;
|
||||
}
|
||||
static guint16 num_of_strings;
|
||||
|
@ -399,15 +385,16 @@ static int
|
|||
eventlog_dissect_element_Record_strings(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, dcerpc_info *di _U_, guint8 *drep _U_)
|
||||
{
|
||||
while(string_offset && num_of_strings){
|
||||
char *str;
|
||||
int len;
|
||||
len=eventlog_get_unicode_string_length(tvb, string_offset);
|
||||
str=tvb_get_faked_unicode(wmem_packet_scope(), tvb, string_offset, len, TRUE);
|
||||
proto_tree_add_string_format(tree, hf_eventlog_Record_string, tvb, string_offset, len*2, str, "string: %s", str);
|
||||
string_offset+=len*2;
|
||||
guint len;
|
||||
|
||||
len=tvb_unicode_strsize(tvb, string_offset);
|
||||
proto_tree_add_item(tree, hf_eventlog_Record_string, tvb, string_offset, len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
|
||||
string_offset+=len;
|
||||
|
||||
num_of_strings--;
|
||||
}
|
||||
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
|
|
@ -104,49 +104,27 @@ eventlog_dissect_element_Record_sid_offset(tvbuff_t *tvb, int offset, packet_inf
|
|||
return offset;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
eventlog_get_unicode_string_length(tvbuff_t *tvb, int offset)
|
||||
{
|
||||
int len;
|
||||
|
||||
len=0;
|
||||
while(1){
|
||||
if(!tvb_get_ntohs(tvb, offset+len*2)){
|
||||
len++;
|
||||
break;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int
|
||||
eventlog_dissect_element_Record_source_name(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint8 *drep _U_)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
guint len;
|
||||
|
||||
len=eventlog_get_unicode_string_length(tvb, offset);
|
||||
str=tvb_get_faked_unicode(wmem_packet_scope(), tvb, offset, len, TRUE);
|
||||
proto_tree_add_string_format(tree, hf_eventlog_Record_source_name, tvb, offset, len*2, str, "source_name: %s", str);
|
||||
len=tvb_unicode_strsize(tvb, offset);
|
||||
proto_tree_add_item(tree, hf_eventlog_Record_source_name, tvb, offset, len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
|
||||
|
||||
offset+=len*2;
|
||||
offset+=len;
|
||||
return offset;
|
||||
}
|
||||
|
||||
static int
|
||||
eventlog_dissect_element_Record_computer_name(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint8 *drep _U_)
|
||||
{
|
||||
char *str;
|
||||
int len;
|
||||
guint len;
|
||||
|
||||
len=eventlog_get_unicode_string_length(tvb, offset);
|
||||
str=tvb_get_faked_unicode(wmem_packet_scope(), tvb, offset, len, TRUE);
|
||||
proto_tree_add_string_format(tree, hf_eventlog_Record_computer_name, tvb, offset, len*2, str, "computer_name: %s", str);
|
||||
len=tvb_unicode_strsize(tvb, offset);
|
||||
proto_tree_add_item(tree, hf_eventlog_Record_computer_name, tvb, offset, len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
|
||||
|
||||
offset+=len*2;
|
||||
offset+=len;
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
@ -176,13 +154,11 @@ static int
|
|||
eventlog_dissect_element_Record_strings(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, guint8 *drep _U_)
|
||||
{
|
||||
while(string_offset && num_of_strings){
|
||||
char *str;
|
||||
int len;
|
||||
guint len;
|
||||
|
||||
len=eventlog_get_unicode_string_length(tvb, string_offset);
|
||||
str=tvb_get_faked_unicode(wmem_packet_scope(), tvb, string_offset, len, TRUE);
|
||||
proto_tree_add_string_format(tree, hf_eventlog_Record_string, tvb, string_offset, len*2, str, "string: %s", str);
|
||||
string_offset+=len*2;
|
||||
len=tvb_unicode_strsize(tvb, string_offset);
|
||||
proto_tree_add_item(tree, hf_eventlog_Record_string, tvb, string_offset, len, ENC_UTF_16|ENC_LITTLE_ENDIAN);
|
||||
string_offset+=len;
|
||||
|
||||
num_of_strings--;
|
||||
}
|
||||
|
|
|
@ -1741,43 +1741,6 @@ tvb_memeql(tvbuff_t *tvb, const gint offset, const guint8 *str, size_t size)
|
|||
}
|
||||
}
|
||||
|
||||
/* Convert a string from Unicode to ASCII. At the moment we fake it by
|
||||
* replacing all non-ASCII characters with a '.' )-: The len parameter is
|
||||
* the number of guint16's to convert from Unicode.
|
||||
*
|
||||
* If scope is set to NULL, returned buffer is allocated by g_malloc()
|
||||
* and must be g_free by the caller. Otherwise memory is automatically
|
||||
* freed when the scope lifetime is reached.
|
||||
*/
|
||||
/* XXX: This has been replaced by tvb_get_string() */
|
||||
char *
|
||||
tvb_get_faked_unicode(wmem_allocator_t *scope, tvbuff_t *tvb, int offset,
|
||||
const int len, const gboolean little_endian)
|
||||
{
|
||||
char *buffer;
|
||||
int i;
|
||||
guint16 character;
|
||||
|
||||
/* Make sure we have enough data before allocating the buffer,
|
||||
so we don't blow up if the length is huge. */
|
||||
tvb_ensure_bytes_exist(tvb, offset, 2*len);
|
||||
|
||||
/* We know we won't throw an exception, so we don't have to worry
|
||||
about leaking this buffer. */
|
||||
buffer = (char *)wmem_alloc(scope, len + 1);
|
||||
|
||||
for (i = 0; i < len; i++) {
|
||||
character = little_endian ? tvb_get_letohs(tvb, offset)
|
||||
: tvb_get_ntohs(tvb, offset);
|
||||
buffer[i] = character < 256 ? character : '.';
|
||||
offset += 2;
|
||||
}
|
||||
|
||||
buffer[len] = 0;
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format the data in the tvb from offset for length ...
|
||||
*/
|
||||
|
|
|
@ -436,19 +436,6 @@ WS_DLL_PUBLIC guint tvb_unicode_strsize(tvbuff_t *tvb, const gint offset);
|
|||
WS_DLL_PUBLIC gint tvb_strnlen(tvbuff_t *tvb, const gint offset,
|
||||
const guint maxlength);
|
||||
|
||||
/** Convert a string from Unicode to ASCII. At the moment we fake it by
|
||||
* assuming all characters are ASCII )-: The len parameter is the number
|
||||
* of guint16's to convert from Unicode.
|
||||
*
|
||||
* XXX - These functions have been superceded by tvb_get_unicode_string()
|
||||
*
|
||||
* If scope is set to NULL, returned buffer is allocated by g_malloc()
|
||||
* and must be g_free by the caller. Otherwise memory is automatically
|
||||
* freed when the scope lifetime is reached.
|
||||
*/
|
||||
WS_DLL_PUBLIC char *tvb_get_faked_unicode(wmem_allocator_t *scope,
|
||||
tvbuff_t *tvb, int offset, const int len, const gboolean little_endian);
|
||||
|
||||
/**
|
||||
* Format the data in the tvb from offset for size ...
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue