[net.bugs.4bsd] Uucp incorrectly chooses 't' protocol

crp@ccivax.UUCP (Chuck Privitera) (05/01/85)

Index:	usr.bin/uucp/cico.c 4.2BSD FIX

Description:
	The (self proclaimed kludgy) IsTcpIp flag is initialized 
	in uucpdefs.[ch] (depending on what version of uucp you
	have) to 0 and in cico.c to 1 if the line is determined
	to be to a TCP/IP host. However, once it is set to 1, it
	never gets cleared. Thus, running the uucp queue with jobs
	queued to TCP/IP machines as well as to non-TCP/IP machines
	AND the TCP/IP machine(s) get called first, when uucico gets
	to the non-TCP/IP machine it will incorrectly choose the
	't' protocol (if the other machine supports it).
Repeat-By:
	Queue a job to a tcp/ip host and to a non-tcp/ip host such
	that the non-tcp/ip site will be called last. If you don't
	talk to any TCP/IP machines, you can add a line like:

	Localhost Any TCP uucp Localhost login: uucp

	To your L.sys file and a line like:

	TCP ttyXX unused 9600 TCP

	To your L-devices file. Then queue something to Localhost
	(or whatever) and to a non-tcp/ip machine (who is gauranteed
	to be called second, and supports the 't' protocol) with
	uucp -r so the job is only queued. Then run uucico by hand
	with debugging turned on so you can see the protocol selection
	and everything. Notice that the 't' protocol will also
	be selected for the non-tcp/ip site.

	If the non-tcp/ip site has a version of the 't' protocol
	compatible with yours (there was a substantial change
	to the 't' protocol sometime around last July), the
	conversation will probably succeed, if not you will probably
	get a core dump in trddata() (because previously the total 
	transmission byte count was sent at the beginning of the
	conversation, and now a byte count is sent at the front of
	each buffer). Even if the conversation goes OK, the integrity
	of the data cannot be guaranteed because nobody was checking
	for integrity (normally, the 'g' protocol or TCP ensures 
	data integrity, but TCP wasn't really the transport
	mechanism, the tty driver was.)
Fix:
	The fix is simple, just explicitly reset the IsTcpIp flag
	if it is determined that the new connection is to a non-tcp/ip
	site. A diff listing of the old and new code follows (line
	numbers are probably off). See the next article to find out
	what you can do to protect yourself from remote sites with
	this problem.

RCS file: RCS/cico.c,v
retrieving revision 1.30
diff -c3 -r1.30 cico.c
*** /tmp/,RCSt1003841	Wed May  1 14:07:27 1985
--- cico.c	Wed May  1 10:47:01 1985
***************
*** 1,5
  #ifndef lint
! static char	*RcsId = "@(#) $Header: cico.c,v 1.30 85/03/17 17:42:51 rick Exp $";
  /* from: @(#)cico.c	5.3 (Berkeley) 10/3/83 */
  #endif !lint
  

--- 1,5 -----
  #ifndef lint
! static char	*RcsId = "@(#) $Header: cico.c,v 1.31 85/05/01 10:42:33 root Exp $";
  /* from: @(#)cico.c	5.3 (Berkeley) 10/3/83 */
  #endif !lint
  
***************
*** 499,505
  		if (isatty(Ifn) ==  0) {
  			IsTcpIp = 1;
  			DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
! 		}
  #endif
  
  		if (setjmp(Sjbuf))

--- 499,506 -----
  		if (isatty(Ifn) ==  0) {
  			IsTcpIp = 1;
  			DEBUG(4, "TCPIP connection -- ioctl-s disabled\n", CNULL);
! 		} else
! 			IsTcpIp = 0;
  #endif
  
  		if (setjmp(Sjbuf))

crp@ccivax.UUCP (Chuck Privitera) (05/01/85)

Index:	usr.bin/uucp/cntrl.c 4.2BSD +FIX

Description:
	blptcl() in cntrl.c blindly builds a string of protocols
	that this machine supports. Thus, as the previous article
	states, a bug in uucico on the remote side manifests itself
	on you (when it doesn't have to). The local machine should not
	tell a remote machine that it is capable of doing protocols
	on a line that has not been conditioned properly for that
	protocol. (i.e. don't say you can run the 't' protocol on
	a normal tty line).
Repeat-By:
	See previous article.
Fix:
	The remote side should know better but while you wait for
	your neighbors to fix the problem in cico.c where the IsTcpIp
	flag is not reset, teach blptcl() not to lie. Here are
	the changes (very similar to fptcl() which is supposed to
	do the final protocol selection):


RCS file: RCS/cntrl.c,v
retrieving revision 1.15
diff  -r1.15 cntrl.c
1c1
< /* $Header: cntrl.c,v 1.15 85/03/17 17:23:08 root Exp $ */
---
> /* $Header: cntrl.c,v 1.16 85/05/01 10:47:03 root Exp $ */
868,869c868,873
< 	for (p = Ptbl, s = str; (*s++ = p->P_id) != '\0'; p++)
< 		;
---
> 	for (p = Ptbl, s = str; p->P_id != '\0'; p++)
> #ifdef BSDTCP
> 		/* Only use 't' protocol on TCP/IP */
> 		if (IsTcpIp || p->P_id != 't')
> #endif
> 			*s++ = p->P_id;