tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Off by ones in wsemul_vt100_subr.c



The attached patch fixes a couple of off-by-ones in the wscons code.

WSEMUL_VT_ID1 and WSEMUL_VT_ID2 are string constants, and sizeof returns the
length of the string _plus_ the 0x00 terminator.  This size is then supplied
to wsdisplay_emulinput, which expects to be passed just the number of
printable characters.

--- sys/dev/wscons/wsemul_vt100_subr.c.dist	2018-12-05 22:42:20.000000000 -0300
+++ sys/dev/wscons/wsemul_vt100_subr.c	2023-01-08 19:25:52.747978285 -0300
@@ -195,7 +195,7 @@
 	switch (A3(edp->modif1, edp->modif2, c)) {
 	    case A3('>', '\0', 'c'): /* DA secondary */
 		wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID2,
-				    sizeof(WSEMUL_VT_ID2));
+				    sizeof(WSEMUL_VT_ID2)-1);
 		break;
 
 	    case A3('\0', '\0', 'J'): /* ED selective erase in display */
@@ -452,7 +452,7 @@
 	    case 'c': /* DA primary */
 		if (ARG(edp, 0) == 0)
 			wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID1,
-					    sizeof(WSEMUL_VT_ID1));
+					    sizeof(WSEMUL_VT_ID1)-1);
 		break;
 	    case 'g': /* TBC */
 		KASSERT(edp->tabs != 0);


Home | Main Index | Thread Index | Old Index