Ethereal-dev: Re: SV: [Ethereal-dev] LLDP Plug-in Submission

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxx>
Date: Thu, 15 Sep 2005 01:00:28 -0700
Gerald Combs wrote:

Why does the dissector have its own MAC_to_str() function?  Wouldn't
ether_to_str() or get_ether_name() work?

As far as I can tell, it would, so I got rid of MAC_to_str() in favor of ether_to_str().

The code beginning at line 619 seems odd:

	strcpy(tempStr,MAC_to_str(mac_addr, 6, ':'));
	proto_tree_add_text(chassis_tree, tvb, (offset+3), 6,
		"Chassis Id: %s", tempStr);
	proto_tree_add_ether_hidden(chassis_tree, hf_chassis_id_mac,
		tvb, (offset+3), 6, mac_addr);

Couldn't this just be

	proto_tree_add_ether(chassis_tree, hf_chassis_id_mac, tvb,
		(offset+3), 6, mac_addr);

It probably should be, so I made it do so, and also got did so in some other cases.

The code uses strcpy() a LOT.  Can these be removed?

I've removed most of them, and am building a change to get rid of the last of them. That should get rid of most if not all of the on-stack buffers for strings, so that there are fewer places where we have to worry about whether the buffer can overflow or not.

I also change it to use tvb_format_text() and tvb_format_stringzpad(), so that non-printable characters in strings don't cause problems.

In dissect_media_tlv(), shouldn't LCI_Length be unsigned in order to
avoid excessive looping?

It already is unsigned.

However, more stringent checks should be done, to make sure it never goes "negative"; I've added those.