bin/69763: /usr/bin/tip strips hi-bit

Bernd Luevelsmeyer bernd at heitec.net
Thu Jul 29 08:50:26 PDT 2004


>Number:         69763
>Category:       bin
>Synopsis:       /usr/bin/tip strips hi-bit
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 29 15:50:21 GMT 2004
>Closed-Date:
>Last-Modified:
>Originator:     Bernd Luevelsmeyer
>Release:        FreeBSD 4.10-STABLE i386
>Organization:
>Environment:
System: FreeBSD 4.10-STABLE

>Description:
The tool /usr/bin/tip (a terminal program for serial lines)
strips input and output to 7 bits. This makes it impossible to
e.g. use german umlauts or accented characters.

>How-To-Repeat:
Connect to a remote system with tip, and type such characters
or 'cat' a file that contains them.

>Fix:
Apply these two patches:

--- usr.bin/tip/tip/tip.c.orig	Sat Jun  2 10:08:24 2001
+++ usr.bin/tip/tip/tip.c	Thu Jul 29 16:07:19 2004
@@ -231,10 +231,10 @@
 	tcgetattr (0, &otermios);
 	ctermios = otermios;
 #ifndef _POSIX_SOURCE
-	ctermios.c_iflag = (IMAXBEL|IXANY|ISTRIP|IXON|BRKINT);
+	ctermios.c_iflag = (IMAXBEL|IXANY|IXON|BRKINT);
 	ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOCTL|ECHOE|ECHOKE);
 #else
-	ctermios.c_iflag = (ISTRIP|IXON|BRKINT);
+	ctermios.c_iflag = (IXON|BRKINT);
 	ctermios.c_lflag = (PENDIN|IEXTEN|ISIG|ECHOE);
 #endif
 	ctermios.c_cflag = (CLOCAL|HUPCL|CREAD|CS8);
@@ -435,7 +435,8 @@
 tipin()
 {
 	int i;
-	char gch, bol = 1;
+	unsigned char gch;
+	char bol = 1;
 
 	atexit(killchild);
 
@@ -455,11 +456,11 @@
 		i = getchar();
 		if (i == EOF)
 			break;
-		gch = i&0177;
-		if ((gch == character(value(ESCAPE))) && bol) {
+		gch = i;
+		if (((gch&0177) == character(value(ESCAPE))) && bol) {
 			if (!(gch = escape()))
 				continue;
-		} else if (!cumode && gch == character(value(RAISECHAR))) {
+		} else if (!cumode && (gch&0177) == character(value(RAISECHAR))) {
 			boolean(value(RAISE)) = !boolean(value(RAISE));
 			continue;
 		} else if (gch == '\r') {
@@ -468,11 +469,11 @@
 			if (boolean(value(HALFDUPLEX)))
 				printf("\r\n");
 			continue;
-		} else if (!cumode && gch == character(value(FORCE))) {
+		} else if (!cumode && (gch&0177) == character(value(FORCE))) {
 			i = getchar();
 			if (i == EOF)
 				break;
-			gch = i & 0177;
+			gch = i;
 		}
 		bol = any(gch, value(EOL));
 		if (boolean(value(RAISE)) && islower(gch))

--- usr.bin/tip/tip/tipout.c.orig	Sat Jun  2 10:08:24 2001
+++ usr.bin/tip/tip/tipout.c	Thu Jul 29 16:05:50 2004
@@ -158,8 +158,6 @@
 		}
 #define	ALLSIGS	sigmask(SIGEMT)|sigmask(SIGTERM)|sigmask(SIGIOT)|sigmask(SIGSYS)
 		omask = sigblock(ALLSIGS);
-		for (cp = buf; cp < buf + cnt; cp++)
-			*cp &= 0177;
 		if (write(1, buf, cnt) < 0)
 			exit(1);
 		if (boolean(value(SCRIPT)) && fscript != NULL) {
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list