Subject: bin/1384: tip parity none fixes
To: None <gnats-bugs@gnats.netbsd.org>
From: Matthieu Herrb <matthieu@laas.fr>
List: netbsd-bugs
Date: 08/19/1995 21:07:24
>Number:         1384
>Category:       bin
>Synopsis:       tip with none parity is not 8 bits clean (with patch)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Aug 19 15:20:02 1995
>Last-Modified:
>Originator:     Matthieu Herrb
>Organization:
		LAAS/CNRS
>Release:        NetBSD-current 95/08/18
>Environment:
	
System: NetBSD cougar 1.0A NetBSD 1.0A (COUGAR) #8: Tue Aug 15 21:08:23 MET DST 1995 matthieu@cougar:/usr/src/sys/arch/i386/compile/COUGAR i386


>Description:
	when parity is set to none in tip, the 8th bit is stripped in 
both input and output, which is incorrect.

>How-To-Repeat:
	try to transmit some chars with 8th bit set in both directions.

>Fix:
diff -c -r tip.orig/cmds.c tip/cmds.c
*** tip.orig/cmds.c	Sun Dec 25 12:30:28 1994
--- tip/cmds.c	Sat Aug 12 18:22:55 1995
***************
*** 144,150 ****
  	pwrite(FD, &r, 1);
  	do
  		read(FD, &c, 1); 
! 	while ((c&0177) != '\n');
  	ioctl(0, TIOCSETC, &defchars);
  	
  	(void) setjmp(intbuf);
--- 144,150 ----
  	pwrite(FD, &r, 1);
  	do
  		read(FD, &c, 1); 
! 	while ((c&STRIP_PAR) != '\n');
  	ioctl(0, TIOCSETC, &defchars);
  	
  	(void) setjmp(intbuf);
***************
*** 152,158 ****
  	start = time(0);
  	for (ct = 0; !quit;) {
  		eof = read(FD, &c, 1) <= 0;
! 		c &= 0177;
  		if (quit)
  			continue;
  		if (eof || any(c, eofchars))
--- 152,158 ----
  	start = time(0);
  	for (ct = 0; !quit;) {
  		eof = read(FD, &c, 1) <= 0;
! 		c &= STRIP_PAR;
  		if (quit)
  			continue;
  		if (eof || any(c, eofchars))
***************
*** 357,363 ****
  					alarm(0);
  					goto out;
  				}
! 			} while ((c&0177) != character(value(PROMPT)));
  			alarm(0);
  		}
  	}
--- 357,363 ----
  					alarm(0);
  					goto out;
  				}
! 			} while ((c&STRIP_PAR) != character(value(PROMPT)));
  			alarm(0);
  		}
  	}
diff -c -r tip.orig/tip.c tip/tip.c
*** tip.orig/tip.c	Fri Aug 11 09:04:08 1995
--- tip/tip.c	Sat Aug 12 18:25:27 1995
***************
*** 363,369 ****
  	}
  
  	while (1) {
! 		gch = getchar()&0177;
  		if ((gch == character(value(ESCAPE))) && bol) {
  			if (!(gch = escape()))
  				continue;
--- 363,369 ----
  	}
  
  	while (1) {
! 		gch = getchar()&STRIP_PAR;
  		if ((gch == character(value(ESCAPE))) && bol) {
  			if (!(gch = escape()))
  				continue;
***************
*** 377,383 ****
  				printf("\r\n");
  			continue;
  		} else if (!cumode && gch == character(value(FORCE)))
! 			gch = getchar()&0177;
  		bol = any(gch, value(EOL));
  		if (boolean(value(RAISE)) && islower(gch))
  			gch = toupper(gch);
--- 377,383 ----
  				printf("\r\n");
  			continue;
  		} else if (!cumode && gch == character(value(FORCE)))
! 			gch = getchar()&STRIP_PAR;
  		bol = any(gch, value(EOL));
  		if (boolean(value(RAISE)) && islower(gch))
  			gch = toupper(gch);
***************
*** 399,405 ****
  	register esctable_t *p;
  	char c = character(value(ESCAPE));
  
! 	gch = (getchar()&0177);
  	for (p = etable; p->e_char; p++)
  		if (p->e_char == gch) {
  			if ((p->e_flags&PRIV) && uid)
--- 399,405 ----
  	register esctable_t *p;
  	char c = character(value(ESCAPE));
  
! 	gch = (getchar()&STRIP_PAR);
  	for (p = etable; p->e_char; p++)
  		if (p->e_char == gch) {
  			if ((p->e_flags&PRIV) && uid)
***************
*** 538,544 ****
  }
  
  static char partab[0200];
! static int bits8;
  
  /*
   * Do a write to the remote machine with the correct parity.
--- 538,544 ----
  }
  
  static char partab[0200];
! int bits8;
  
  /*
   * Do a write to the remote machine with the correct parity.
diff -c -r tip.orig/tip.h tip/tip.h
*** tip.orig/tip.h	Thu Dec  8 12:23:56 1994
--- tip/tip.h	Sat Aug 12 18:24:11 1995
***************
*** 241,246 ****
--- 241,249 ----
  #define NOFILE	((FILE *)NULL)
  #define NOPWD	((struct passwd *)0)
  
+ extern int bits8;
+ #define STRIP_PAR (bits8 ? 0377 : 0177)
+ 
  struct sgttyb	arg;		/* current mode of local terminal */
  struct sgttyb	defarg;		/* initial mode of local terminal */
  struct tchars	tchars;		/* current state of terminal */
diff -c -r tip.orig/tipout.c tip/tipout.c
*** tip.orig/tipout.c	Thu Dec  8 12:23:58 1994
--- tip/tipout.c	Sat Aug 12 18:34:58 1995
***************
*** 147,153 ****
  #define	ALLSIGS	sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS)
  		omask = sigblock(ALLSIGS);
  		for (cp = buf; cp < buf + cnt; cp++)
! 			*cp &= 0177;
  		write(1, buf, cnt);
  		if (boolean(value(SCRIPT)) && fscript != NULL) {
  			if (!boolean(value(BEAUTIFY))) {
--- 147,153 ----
  #define	ALLSIGS	sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS)
  		omask = sigblock(ALLSIGS);
  		for (cp = buf; cp < buf + cnt; cp++)
! 			*cp &= STRIP_PAR;
  		write(1, buf, cnt);
  		if (boolean(value(SCRIPT)) && fscript != NULL) {
  			if (!boolean(value(BEAUTIFY))) {

>Audit-Trail:
>Unformatted: