Subject: kern/5954: wscons vt100 emulation can't handle bogus scrolling region
To: None <gnats-bugs@gnats.netbsd.org>
From: Dave Huang <khym@bga.com>
List: netbsd-bugs
Date: 08/11/1998 21:21:30
>Number:         5954
>Category:       kern
>Synopsis:       wscons vt100 emulation can't handle bogus scrolling region
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 11 19:35:00 1998
>Last-Modified:
>Originator:     Dave Huang
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 22 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Release:        NetBSD-current as of August 10, 1998
>Environment:
	
System: NetBSD dahan.metonymy.com 1.3G NetBSD 1.3G (SPIFF) #237: Tue Aug 11 21:03:03 CDT 1998 khym@dahan.metonymy.com:/usr/src.local/sys/arch/i386/compile/SPIFF i386


>Description:
	The wscons vt100 emulation may crash if an invalid scrolling
region is set (for example, the top margin is lower than the bottom
margin).
>How-To-Repeat:
	$ echo '^[[20;10r', then hit enter a couple of times. Or run
vttest (sys/arch/i386/isa/pcvt/Util/vttest), choose option 9 (Test of
known bugs), then option 9 again (Funny scroll regions).

P.S. The third screen of "Test of cursor movements," "Test of
cursor-control characters inside ESC sequences" doesn't work either.
And my Alt key doesn't work as a Meta key inside emacs.
>Fix:
	I don't know what the exact behavior is supposed to be, but
bug_s() in vttest says:

  decstbm(20,10);	/* 20-10=-10, < 2, so no scroll region. */

So, perhaps something like this?

--- /usr/src/sys/dev/wscons/wsemul_vt100_subr.c	Tue Jun 30 06:13:32 1998
+++ wsemul_vt100_subr.c	Tue Aug 11 21:02:09 1998
@@ -587,7 +587,7 @@
 		}
 		break;
 	    case 'r': /* DECSTBM set top/bottom margins */
-		if (ARG(0) == 0 && ARG(1) == 0) {
+		if (((int)DEF1_ARG(1) - (int)DEF1_ARG(0)) < 2) {
 			edp->scrreg_startrow = 0;
 			edp->scrreg_nrows = edp->nrows;
 		} else {
>Audit-Trail:
>Unformatted: