Ethereal-dev: Re: [ethereal-dev] SIGBUS in packet-ntp

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

From: Guy Harris <guy@xxxxxxxxxx>
Date: Thu, 2 Dec 1999 13:59:59 -0800 (PST)
> 	1) "primary_sources[]" is an array of structures whose two
> 	   members are "char *"s - comparing the reference clock ID
> 	   with the lower 32 bits of a random address in Ethereal's
> 	   address space doesn't make sense;

No, it's comparing the reference clock ID with a four-byte character
string - but, in that case, "memcmp()" should be used, as it doesn't
care about alignment (or byte order):

	/* Now, there is a problem with secondary servers.  Standards asks
	 * from stratum-2 - stratum-15 servers to set this to the low order
	 * 32 bits of the latest transmit timestamp of the reference source.
	 * But, all V3 and V4 servers set this to IP adress of their higher
	 * level server. My decision was to resolve this address.
	 */
	if (*pkt->stratum <= 1) {
		strcpy (buff, "unindentified reference source"); 
		for (i = 0; primary_sources[i].id; i++)
			if (memcmp(pkt->refid, primary_sources[i].id, 4) == 0)
				strcpy (buff, primary_sources[i].data); 
	} else strcpy (buff, get_hostname (pntohl(pkt->refid)));

And, to remove an unnecessary indirection, "primary_sources[]" can be
declared as:

	static const struct {
	        char id[4];
	        char *data;
	} primary_sources[] = {

		...