Add a new api to allow dissection of the array payload as a whole. Bug 9307 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9307)

From Matthieu Patou 

svn path=/trunk/; revision=52743
This commit is contained in:
Michael Mann 2013-10-21 18:46:52 +00:00
parent 772fb97f76
commit 15294a1261
2 changed files with 45 additions and 12 deletions

View File

@ -1469,11 +1469,16 @@ dissect_ndr_ucarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
return offset;
}
/* function to dissect a unidimensional conformant and varying array */
int
dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
/* function to dissect a unidimensional conformant and varying array
* depending on the dissection function passed as a parameter,
* content of the array will be dissected as a block or byte by byte
*/
static int
dissect_ndr_ucvarray_core(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_t *fnct)
dcerpc_dissect_fnct_t *fnct_bytes,
dcerpc_dissect_fnct_blk_t *fnct_block)
{
guint32 i;
dcerpc_info *di;
@ -1516,16 +1521,37 @@ dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree_add_uint(tree, hf_dcerpc_array_actual_count, tvb, di->array_actual_count_offset, conformance_size, di->array_actual_count);
/* real run, dissect the elements */
for(i=0 ;i<di->array_actual_count; i++) {
old_offset = offset;
offset = (*fnct)(tvb, offset, pinfo, tree, drep);
if (offset <= old_offset)
THROW(ReportedBoundsError);
if (fnct_block) {
old_offset = offset;
offset = (*fnct_block)(tvb, offset, di->array_actual_count, pinfo, tree, drep);
} else {
for(i=0 ;i<di->array_actual_count; i++) {
old_offset = offset;
offset = (*fnct_bytes)(tvb, offset, pinfo, tree, drep);
if (offset <= old_offset)
THROW(ReportedBoundsError);
}
}
}
return offset;
}
int
dissect_ndr_ucvarray_block(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_blk_t *fnct)
{
return dissect_ndr_ucvarray_core(tvb, offset, pinfo, tree, drep, NULL, fnct);
}
int
dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_t *fnct)
{
return dissect_ndr_ucvarray_core(tvb, offset, pinfo, tree, drep, fnct, NULL);
}
/* function to dissect a unidimensional varying array */
int
dissect_ndr_uvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,

View File

@ -229,6 +229,7 @@ int dissect_ndr_uint3264 (tvbuff_t *tvb, gint offset, packet_info *pinfo,
int hfindex, guint3264 *pdata);
typedef int (dcerpc_dissect_fnct_t)(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 *drep);
typedef int (dcerpc_dissect_fnct_blk_t)(tvbuff_t *tvb, int offset, int length, packet_info *pinfo, proto_tree *tree, guint8 *drep);
typedef void (dcerpc_callback_fnct_t)(packet_info *pinfo, proto_tree *tree, proto_item *item, tvbuff_t *tvb, int start_offset, int end_offset, void *callback_args);
@ -261,10 +262,16 @@ int dissect_ndr_ucarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_t *fnct);
/* dissect a NDR unidimensional conformant and varying array */
/* dissect a NDR unidimensional conformant and varying array
* each byte in the array is processed separately
*/
int dissect_ndr_ucvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_t *fnct);
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_t *fnct);
int dissect_ndr_ucvarray_block(tvbuff_t *tvb, gint offset, packet_info *pinfo,
proto_tree *tree, guint8 *drep,
dcerpc_dissect_fnct_blk_t *fnct);
/* dissect a NDR unidimensional varying array */
int dissect_ndr_uvarray(tvbuff_t *tvb, gint offset, packet_info *pinfo,