Date: Mon, 15 Feb 2021 08:22:01 GMT From: Toomas Soome <tsoome@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 76702e90d007 - stable/13 - vt: terminal size can grow too big with small font Message-ID: <202102150822.11F8M1tM018529@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by tsoome: URL: https://cgit.FreeBSD.org/src/commit/?id=76702e90d0072452da5105033931532ae013dbf1 commit 76702e90d0072452da5105033931532ae013dbf1 Author: Toomas Soome <tsoome@FreeBSD.org> AuthorDate: 2021-01-21 22:18:56 +0000 Commit: Toomas Soome <tsoome@FreeBSD.org> CommitDate: 2021-02-14 21:37:45 +0000 vt: terminal size can grow too big with small font vt is using static buffers for on screen data, the buffer size is calculated based on maximum supported screen size and 8x16 font. When using hi-res graphics and very smaller than 8x16 font, we need to be careful not to overflow static buffers in vt. Testing: I did test by building smaller buffers than vt currently is using, royger was testing on actual 4k capable hardware. MFC after: 1 week Tested by: royger (cherry-picked from 32bf05ad89aaa93f4dd27e3721f4cb52cf57fa03) --- sys/dev/vt/vt_core.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/sys/dev/vt/vt_core.c b/sys/dev/vt/vt_core.c index 05c383829f49..e4a8288962c4 100644 --- a/sys/dev/vt/vt_core.c +++ b/sys/dev/vt/vt_core.c @@ -640,8 +640,10 @@ vt_termsize(struct vt_device *vd, struct vt_font *vf, term_pos_t *size) size->tp_row -= vt_logo_sprite_height; size->tp_col = vd->vd_width; if (vf != NULL) { - size->tp_row /= vf->vf_height; - size->tp_col /= vf->vf_width; + size->tp_row = MIN(size->tp_row / vf->vf_height, + PIXEL_HEIGHT(VT_FB_MAX_HEIGHT)); + size->tp_col = MIN(size->tp_col / vf->vf_width, + PIXEL_WIDTH(VT_FB_MAX_WIDTH)); } } @@ -660,8 +662,10 @@ vt_termrect(struct vt_device *vd, struct vt_font *vf, term_rect_t *rect) rect->tr_begin.tp_row = howmany(rect->tr_begin.tp_row, vf->vf_height); - rect->tr_end.tp_row /= vf->vf_height; - rect->tr_end.tp_col /= vf->vf_width; + rect->tr_end.tp_row = MIN(rect->tr_end.tp_row / vf->vf_height, + PIXEL_HEIGHT(VT_FB_MAX_HEIGHT)); + rect->tr_end.tp_col = MIN(rect->tr_end.tp_col / vf->vf_width, + PIXEL_WIDTH(VT_FB_MAX_WIDTH)); } } @@ -675,8 +679,10 @@ vt_winsize(struct vt_device *vd, struct vt_font *vf, struct winsize *size) size->ws_row = size->ws_ypixel; size->ws_col = size->ws_xpixel = vd->vd_width; if (vf != NULL) { - size->ws_row /= vf->vf_height; - size->ws_col /= vf->vf_width; + size->ws_row = MIN(size->ws_row / vf->vf_height, + PIXEL_HEIGHT(VT_FB_MAX_HEIGHT)); + size->ws_col = MIN(size->ws_col / vf->vf_width, + PIXEL_WIDTH(VT_FB_MAX_WIDTH)); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202102150822.11F8M1tM018529>