Ensure the result from signed subtraction under modulus does not

become negative.

Submitted by:		Oliver Pinter <oliver.pinter@hardenedbsd.org>
MFC after:		3 days
This commit is contained in:
Hans Petter Selasky 2015-05-10 17:11:04 +00:00
parent 53d1c63711
commit b1b7114036

View File

@ -785,7 +785,7 @@ vt_processkey(keyboard_t *kbd, struct vt_device *vd, int c)
return (0);
case PREV:
/* Switch to previous VT. */
c = (vw->vw_number - 1) % VT_MAXWINDOWS;
c = (vw->vw_number + VT_MAXWINDOWS - 1) % VT_MAXWINDOWS;
vw = vd->vd_windows[c];
vt_proc_window_switch(vw);
return (0);