patch-1.3.37 linux/drivers/char/n_tty.c

Next file: linux/drivers/net/3c503.c
Previous file: linux/drivers/cdrom/cdu31a.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.36/linux/drivers/char/n_tty.c linux/drivers/char/n_tty.c
@@ -255,24 +255,31 @@
 					tail = (tail+1) & (N_TTY_BUF_SIZE-1);
 				}
 
+				/* should never happen */
+				if (tty->column > 0x80000000)
+					tty->column = 0; 
+
 				/* Now backup to that column. */
 				while (tty->column > col) {
 					/* Can't use opost here. */
 					put_char('\b', tty);
-					tty->column--;
+					if (tty->column > 0)
+						tty->column--;
 				}
 			} else {
 				if (iscntrl(c) && L_ECHOCTL(tty)) {
 					put_char('\b', tty);
 					put_char(' ', tty);
 					put_char('\b', tty);
-					tty->column--;
+					if (tty->column > 0)
+						tty->column--;
 				}
 				if (!iscntrl(c) || L_ECHOCTL(tty)) {
 					put_char('\b', tty);
 					put_char(' ', tty);
 					put_char('\b', tty);
-					tty->column--;
+					if (tty->column > 0)
+						tty->column--;
 				}
 			}
 		}
@@ -696,6 +703,8 @@
 	}
 	memset(tty->read_buf, 0, N_TTY_BUF_SIZE);
 	tty->read_head = tty->read_tail = tty->read_cnt = 0;
+	tty->canon_head = tty->canon_data = tty->erasing = 0;
+	tty->column = 0;
 	memset(tty->read_flags, 0, sizeof(tty->read_flags));
 	n_tty_set_termios(tty, 0);
 	tty->minimum_to_wake = 1;

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this