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

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