]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
font: Reject fonts with negative max_char_width or max_char_height
authorZhang Boyang <zhangboyang.id@gmail.com>
Mon, 5 Dec 2022 11:29:38 +0000 (19:29 +0800)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 10 Jan 2023 15:06:03 +0000 (16:06 +0100)
If max_char_width or max_char_height are negative wrong values can be propagated
by grub_font_get_max_char_width() or grub_font_get_max_char_height(). Prevent
this from happening.

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

index 674043d0d186b592bf1df7e30f4c292853e1389f..24adcb35a8676b7abfc37069c7780e4bfef408b3 100644 (file)
@@ -644,8 +644,8 @@ grub_font_load (const char *filename)
               font->max_char_width, font->max_char_height, font->num_chars);
 #endif
 
-  if (font->max_char_width == 0
-      || font->max_char_height == 0
+  if (font->max_char_width <= 0
+      || font->max_char_height <= 0
       || font->num_chars == 0
       || font->char_index == 0 || font->ascent == 0 || font->descent == 0)
     {