]> git.proxmox.com Git - grub2.git/commit
term/gfxterm: Don't set up a font with glyphs that are too big
authorDaniel Axtens <dja@axtens.net>
Fri, 15 Jan 2021 09:03:20 +0000 (20:03 +1100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 14:54:18 +0000 (15:54 +0100)
commit829329bddb2c3e623270cc634cc9ab32e6455fe7
treea35ebfdf8105545f390f8a6a258ead0a22dd012a
parent8338a8238f08d9f3ae4c2ddfff0603eff80af9e2
term/gfxterm: Don't set up a font with glyphs that are too big

Catch the case where we have a font so big that it causes the number of
rows or columns to be 0. Currently we continue and allocate a
virtual_screen.text_buffer of size 0. We then try to use that for glpyhs
and things go badly.

On the emu platform, malloc() may give us a valid pointer, in which case
we'll access heap memory which we shouldn't. Alternatively, it may give us
NULL, in which case we'll crash. For other platforms, if I understand
grub_memalign() correctly, we will receive a valid but small allocation
that we will very likely later overrun.

Prevent the creation of a virtual screen that isn't at least 40 cols
by 12 rows. This is arbitrary, but it seems that if your width or height
is half a standard 80x24 terminal, you're probably going to struggle to
read anything anyway.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/term/gfxterm.c