Skip to content

Commit 65a01e6

Browse files
committed
fbcon: Disallow setting font bigger than screen size
Prevent that users set a font size which is bigger than the physical screen. It's unlikely this may happen (because screens are usually much larger than the fonts and each font char is limited to 32x32 pixels), but it may happen on smaller screens/LCD displays. Signed-off-by: Helge Deller <[email protected]> Reviewed-by: Daniel Vetter <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Cc: [email protected] # v4.14+
1 parent 3663a2f commit 65a01e6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/video/fbdev/core/fbcon.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
24692469
if (charcount != 256 && charcount != 512)
24702470
return -EINVAL;
24712471

2472+
/* font bigger than screen resolution ? */
2473+
if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) ||
2474+
h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))
2475+
return -EINVAL;
2476+
24722477
/* Make sure drawing engine can handle the font */
24732478
if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
24742479
!(info->pixmap.blit_y & (1 << (font->height - 1))))

0 commit comments

Comments
 (0)