SPOOLSS: Try to avoid an infinite loop.

Use tvb_reported_length_remaining in dissect_spoolss_uint16uni. Make
sure our offset always increments in dissect_spoolss_keybuffer.

Change-Id: I7017c9685bb2fa27161d80a03b8fca4ef630e793
Reviewed-on: https://code.wireshark.org/review/14687
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
dissect_DRIVER_INFO_6(tvbuff_t *tvb, int offset,
				 packet_info *pinfo, proto_tree *tree,
				 dcerpc_info *di, guint8 *drep)
{
	proto_tree *subtree;
	int struct_start = offset;

	subtree = proto_tree_add_subtree(
			tree, tvb, offset, 0, ett_DRIVER_INFO_6, NULL, "Driver info level 6");

	offset = dissect_ndr_uint32(tvb, offset, pinfo, subtree, di, drep,
			hf_driverinfo_cversion, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_drivername,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_environment,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_driverpath,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_datafile,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_configfile,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_helpfile,
			struct_start, NULL);

	offset = dissect_spoolss_relstrarray(
			tvb, offset, pinfo, subtree, di, drep, hf_dependentfiles,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_monitorname,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_defaultdatatype,
			struct_start, NULL);

	offset = dissect_spoolss_relstrarray(
			tvb, offset, pinfo, subtree, di, drep, hf_previousdrivernames,
			struct_start, NULL);

	offset = dissect_ndr_nt_NTTIME (
			tvb, offset, pinfo, subtree, di, drep,hf_driverdate);

	offset = dissect_ndr_uint32(
			tvb, offset, pinfo, subtree, di, drep, hf_padding,
			NULL);

	offset = dissect_ndr_uint32(
			tvb, offset, pinfo, subtree, di, drep, hf_driver_version_low,
			NULL);

	offset = dissect_ndr_uint32(
			tvb, offset, pinfo, subtree, di, drep, hf_driver_version_high,
			NULL);


	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_mfgname,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_oemurl,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_hardwareid,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_provider,
			struct_start, NULL);

	return offset;
}

dissect_DRIVER_INFO_6(tvbuff_t *tvb, int offset,
				 packet_info *pinfo, proto_tree *tree,
				 dcerpc_info *di, guint8 *drep)
{
	proto_tree *subtree;
	int struct_start = offset;

	subtree = proto_tree_add_subtree(
			tree, tvb, offset, 0, ett_DRIVER_INFO_6, NULL, "Driver info level 6");

	offset = dissect_ndr_uint32(tvb, offset, pinfo, subtree, di, drep,
			hf_driverinfo_cversion, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_drivername,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_environment,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_driverpath,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_datafile,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_configfile,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_helpfile,
			struct_start, NULL);

	offset = dissect_spoolss_relstrarray(
			tvb, offset, pinfo, subtree, di, drep, hf_dependentfiles,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_monitorname,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_defaultdatatype,
			struct_start, NULL);

	offset = dissect_spoolss_relstrarray(
			tvb, offset, pinfo, subtree, di, drep, hf_previousdrivernames,
			struct_start, NULL);

	offset = dissect_ndr_nt_NTTIME (
			tvb, offset, pinfo, subtree, di, drep,hf_driverdate);

	offset = dissect_ndr_uint32(
			tvb, offset, pinfo, subtree, di, drep, hf_padding,
			NULL);

	offset = dissect_ndr_uint32(
			tvb, offset, pinfo, subtree, di, drep, hf_driver_version_low,
			NULL);

	offset = dissect_ndr_uint32(
			tvb, offset, pinfo, subtree, di, drep, hf_driver_version_high,
			NULL);


	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_mfgname,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_oemurl,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_hardwareid,
			struct_start, NULL);

	offset = dissect_spoolss_relstr(
			tvb, offset, pinfo, subtree, di, drep, hf_provider,
			struct_start, NULL);

	return offset;
}
