Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Aug 2001 02:20:01 -0700 (PDT)
From:      Kris Kennaway <kris@obsecurity.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: misc/29867: 4.3 timed master can't sync Red Hat Linux 6.0 box
Message-ID:  <200108190920.f7J9K1E43753@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR misc/29867; it has been noted by GNATS.

From: Kris Kennaway <kris@obsecurity.org>
To: Steve Whiteley <stevew@wrcad.com>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: misc/29867: 4.3 timed master can't sync Red Hat Linux 6.0 box
Date: Sun, 19 Aug 2001 02:18:52 -0700

 --4zI0WCX1RcnW9Hbu
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 > The problem is that the sizeof(struct tsp) differs on the two systems.
 > Made the following change in readmsg.c near line 215, which seems to have=
  fixed the problem.
 > ----------------------------------------------------------------------
 >         length =3D sizeof(from);
 >         if ((n =3D recvfrom(sock, (char *)&msgin, sizeof(struct tsp), 0,
 >                  (struct sockaddr*)&from, &length)) < 0) {
 >             syslog(LOG_ERR, "recvfrom: %m");
 >             exit(1);
 >         }
 > /* SRW */
 > /* Here is a bug: the sizeof(struct tsp) is OS dependent, depending on the
 >  * length of the tsp_name field (MAXHOSTNAMELEN) which is, e.g., 256 for
 >  * FreeBSD 4.3 and 64 for RH Linux 6.0.  Keep this as a sanity check,
 >  * but assume that the name field is 64 or larger
 >  */ =20
 >         if (n < (ssize_t)sizeof(struct tsp) - MAXHOSTNAMELEN + 64) {
 > /*
 >         if (n < (ssize_t)sizeof(struct tsp)) {
 > */
 >             syslog(LOG_NOTICE,
 >                 "short packet (%u/%u bytes) from %s",
 >                   n, sizeof(struct tsp),
 >                   inet_ntoa(from.sin_addr));
 >             continue; =20
 >         }
 
 I think this is a more complete fix.  According to
 
   http://sunsite.berkeley.edu/Dienst/UI/2.0/Describe/ncstrl.ucb/CSD-85-250
 
 the original 4.3BSD code had sizeof(tsp.tsp_name) =3D=3D 32, so that's
 probably a safe minimum packet size to use.  Can you please test?
 
 Kris
 
 Index: timed/readmsg.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /mnt/ncvs/src/usr.sbin/timed/timed/readmsg.c,v
 retrieving revision 1.7
 diff -u -r1.7 readmsg.c
 --- timed/readmsg.c	2001/01/01 18:43:21	1.7
 +++ timed/readmsg.c	2001/08/19 09:14:07
 @@ -212,10 +212,15 @@
  			syslog(LOG_ERR, "recvfrom: %m");
  			exit(1);
  		}
 -		if (n < (ssize_t)sizeof(struct tsp)) {
 +		/*
 +		 * The 4.3BSD protocol spec had a 32-byte tsp_name field, and
 +		 * this is still OS-dependent.  Demand that the packet is at
 +		 * least long enough to hold a 4.3BSD packet.
 +		 */
 +		if (n < (ssize_t)(sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) {
  			syslog(LOG_NOTICE,
  			    "short packet (%u/%u bytes) from %s",
 -			      n, sizeof(struct tsp),
 +			      n, sizeof(struct tsp) - MAXHOSTNAMELEN + 32,
  			      inet_ntoa(from.sin_addr));
  			continue;
  		}
 Index: timedc/cmds.c
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
 RCS file: /mnt/ncvs/src/usr.sbin/timed/timedc/cmds.c,v
 retrieving revision 1.7
 diff -u -r1.7 cmds.c
 --- timedc/cmds.c	2001/05/09 08:37:18	1.7
 +++ timedc/cmds.c	2001/08/19 09:17:16
 @@ -332,10 +332,15 @@
  				warn("recvfrom");
  				continue;
  			}
 -			if (cc < sizeof(struct tsp)) {
 +			/*
 +			 * The 4.3BSD protocol spec had a 32-byte tsp_name field, and
 +			 * this is still OS-dependent.  Demand that the packet is at
 +			 * least long enough to hold a 4.3BSD packet.
 +			 */
 +			if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) {
  				fprintf(stderr,=20
  				   "short packet (%u/%u bytes) from %s\n",
 -				   cc, sizeof(struct tsp),
 +				   cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32,
  				   inet_ntoa(from.sin_addr));
  				continue;
  			}
 @@ -484,9 +489,15 @@
  			warn("recvfrom");
  			return;
  		}
 -		if (cc < sizeof(struct tsp)) {
 -			fprintf(stderr, "short pack (%u/%u bytes) from %s\n",
 -			   cc, sizeof(struct tsp), inet_ntoa(from.sin_addr));
 +		/*
 +		 * The 4.3BSD protocol spec had a 32-byte tsp_name field, and
 +		 * this is still OS-dependent.  Demand that the packet is at
 +		 * least long enough to hold a 4.3BSD packet.
 +		 */
 +		if (cc < (sizeof(struct tsp) - MAXHOSTNAMELEN + 32)) {
 +			fprintf(stderr, "short packet (%u/%u bytes) from %s\n",
 +			    cc, sizeof(struct tsp) - MAXHOSTNAMELEN + 32,
 +			    inet_ntoa(from.sin_addr));
  			return;
  		}
  		bytehostorder(&msg);
 
 
 --4zI0WCX1RcnW9Hbu
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQE7f4R7Wry0BWjoQKURAmHOAKCb8u6QOI/gl8VxPQOhIRpX5JIzzACdHL/Z
 sYN3B6/EEKDmbX9mpo5mFcI=
 =ODjL
 -----END PGP SIGNATURE-----
 
 --4zI0WCX1RcnW9Hbu--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108190920.f7J9K1E43753>