Blame SOURCES/0279-font-Reject-glyphs-exceeds-font-max_glyph_width-or-f.patch

fd0330
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
fd0330
From: Zhang Boyang <zhangboyang.id@gmail.com>
fd0330
Date: Wed, 3 Aug 2022 19:45:33 +0800
fd0330
Subject: [PATCH] font: Reject glyphs exceeds font->max_glyph_width or
fd0330
 font->max_glyph_height
fd0330
fd0330
Check glyph's width and height against limits specified in font's
fd0330
metadata. Reject the glyph (and font) if such limits are exceeded.
fd0330
fd0330
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
fd0330
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
fd0330
(cherry picked from commit 5760fcfd466cc757540ea0d591bad6a08caeaa16)
fd0330
---
fd0330
 grub-core/font/font.c | 4 +++-
fd0330
 1 file changed, 3 insertions(+), 1 deletion(-)
fd0330
fd0330
diff --git a/grub-core/font/font.c b/grub-core/font/font.c
fd0330
index d09bb38d89..2f09a4a55b 100644
fd0330
--- a/grub-core/font/font.c
fd0330
+++ b/grub-core/font/font.c
fd0330
@@ -760,7 +760,9 @@ grub_font_get_glyph_internal (grub_font_t font, grub_uint32_t code)
fd0330
 	  || read_be_uint16 (font->file, &height) != 0
fd0330
 	  || read_be_int16 (font->file, &xoff) != 0
fd0330
 	  || read_be_int16 (font->file, &yoff) != 0
fd0330
-	  || read_be_int16 (font->file, &dwidth) != 0)
fd0330
+	  || read_be_int16 (font->file, &dwidth) != 0
fd0330
+	  || width > font->max_char_width
fd0330
+	  || height > font->max_char_height)
fd0330
 	{
fd0330
 	  remove_font (font);
fd0330
 	  return 0;