Bug 10291 - pidl generates bad Wireshark dissector code for frstrans.idl
Summary: pidl generates bad Wireshark dissector code for frstrans.idl
Status: ASSIGNED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: PIDL and libndr (show other bugs)
Version: unspecified
Hardware: All All
: P5 major (vote)
Target Milestone: ---
Assignee: Samba QA Contact
QA Contact: Jelmer Vernooij
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-11-24 22:11 UTC by Guy Harris
Modified: 2019-04-01 21:21 UTC (History)
1 user (show)

See Also:


Attachments
Current frstrans.idl in Wireshark trunk (7.38 KB, application/octet-stream)
2013-11-24 22:11 UTC, Guy Harris
no flags Details
Current idl_types.h from Wireshark trunk (1.99 KB, application/octet-stream)
2013-11-24 22:11 UTC, Guy Harris
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Guy Harris 2013-11-24 22:11:05 UTC
Created attachment 9475 [details]
Current frstrans.idl in Wireshark trunk

The frstrans.idl file in Wireshark has

	typedef enum {
		FRSTRANS_RDC_FILTER_GENERIC	= 0x0000,
		FRSTRANS_RDC_FILTER_MAX		= 0x0001,
		FRSTRANS_RDC_FILTER_POINT	= 0x0002,
		FRSTRANS_RDC_MAX_ALGORITHM	= 0x0003
	} frstrans_RdcChunckerAlgorithm;

		...

	typedef [switch_type(frstrans_RdcChunckerAlgorithm)] union {
		[case(FRSTRANS_RDC_FILTER_GENERIC)]
			frstrans_RdcParameterGeneric filter_generic;
		[case(FRSTRANS_RDC_FILTER_MAX)]
			frstrans_RdcParameterFilterMax filter_max;
		[case(FRSTRANS_RDC_FILTER_POINT)]
			frstrans_RdcParameterFilterPoint filter_point;
	} frstrans_RdcParameterUnion;

	typedef struct {
		frstrans_RdcChunckerAlgorithm rdc_chunker_algorithm;
		[switch_is(rdc_chunker_algorithm)] frstrans_RdcParameterUnion u;
	} frstrans_RdcParameters;

and pidl generates


/* IDL: struct { */
/* IDL: 	frstrans_RdcChunckerAlgorithm rdc_chunker_algorithm; */
/* IDL: 	[switch_is(rdc_chunker_algorithm)] frstrans_RdcParameterUnion u; */
/* IDL: } */

static int
frstrans_dissect_element_RdcParameters_rdc_chunker_algorithm(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, guint1632 *rdc_chunker_algorithm)
{
	offset = frstrans_dissect_enum_RdcChunckerAlgorithm(tvb, offset, pinfo, tree, drep, hf_frstrans_frstrans_RdcParameters_rdc_chunker_algorithm, rdc_chunker_algorithm);

	return offset;
}

static int
frstrans_dissect_element_RdcParameters_u(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, guint8 *drep _U_, guint1632 *rdc_chunker_algorithm)
{
	offset = frstrans_dissect_RdcParameterUnion(tvb, offset, pinfo, tree, drep, hf_frstrans_frstrans_RdcParameters_u, *rdc_chunker_algorithm);

	return offset;
}

int
frstrans_dissect_struct_RdcParameters(tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *parent_tree _U_, guint8 *drep _U_, int hf_index _U_, guint32 param _U_)
{
	guint1632 rdc_chunker_algorithm;
	 u;
	proto_item *item = NULL;
	proto_tree *tree = NULL;
	dcerpc_info *di = (dcerpc_info *)pinfo->private_data;
	int old_offset;

	ALIGN_TO_3_BYTES;

	old_offset = offset;

	if (parent_tree) {
		item = proto_tree_add_item(parent_tree, hf_index, tvb, offset, -1, ENC_NA);
		tree = proto_item_add_subtree(item, ett_frstrans_frstrans_RdcParameters);
	}
	
	offset = frstrans_dissect_element_RdcParameters_rdc_chunker_algorithm(tvb, offset, pinfo, tree, drep, &rdc_chunker_algorithm);

	offset = frstrans_dissect_element_RdcParameters_u(tvb, offset, pinfo, tree, drep, &rdc_chunker_algorithm);


	proto_item_set_len(item, offset-old_offset);


	if (di->call_data->flags & DCERPC_IS_NDR64) {
		ALIGN_TO_3_BYTES;
	}

	return offset;
}

for it.  Note the declaration of a variable "u" with no type, and the absence of any references to "u", in frstrans_dissect_struct_RdcParameters().

I suspect the code generator is confused and thinks that u is used as a selector in a switch; it has a type that's not an integral type, so it doesn't generate a valid GLib type for it.

I've attached frstrans.idl, along with idl_types.h.
Comment 1 Guy Harris 2013-11-24 22:11:38 UTC
Created attachment 9476 [details]
Current idl_types.h from Wireshark trunk
Comment 2 Matthieu Patou 2014-10-12 23:38:54 UTC
With the changes made in my iolab2013 branch (see http://git.samba.org/?p=mat/samba.git;a=shortlog;h=refs/heads/iolab2013) frstrans.idl compiles fine and also dissect mostly fine.
Comment 3 Guy Harris 2016-07-27 22:33:30 UTC
(In reply to Matthieu Patou from comment #2)

OK, so have those changes been merged into the main Samba repository?  The Git link for  the changes in the branch in question doesn't work any more.
Comment 4 Douglas Bagnall 2019-03-05 22:07:20 UTC
Bug #10825 comment 1 suggests that fixing that (which means merging various Wireshark patches) will fix this. I'm prepared to believe it.
Comment 5 Andrew Bartlett 2019-04-01 21:21:17 UTC
Moving PIDL bugs into Samba as we do not release PIDL separately.