]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
font: Reject glyphs exceeds font->max_glyph_width or font->max_glyph_height
authorZhang Boyang <zhangboyang.id@gmail.com>
Wed, 3 Aug 2022 11:45:33 +0000 (19:45 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Mon, 14 Nov 2022 19:24:39 +0000 (20:24 +0100)
Check glyph's width and height against limits specified in font's
metadata. Reject the glyph (and font) if such limits are exceeded.

Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/font/font.c

index 42189c3254a9a31b1d2f9a9d5897162e9cfcfe1d..756ca0abf129e220664d3fc19469461f5880a351 100644 (file)
@@ -760,7 +760,9 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
          || read_be_uint16 (font->file, &height) != 0
          || read_be_int16 (font->file, &xoff) != 0
          || read_be_int16 (font->file, &yoff) != 0
-         || read_be_int16 (font->file, &dwidth) != 0)
+         || read_be_int16 (font->file, &dwidth) != 0
+         || width > font->max_char_width
+         || height > font->max_char_height)
        {
          remove_font (font);
          return 0;