:: commit 4b91cc1c706e0186c80a54e67680ee9a234bde4d

Mintsuki <mintsuki@protonmail.com> — 2025-12-28 13:27

parents: aa0702ae0c

lib/gterm: Add safeguard against font file being too small

diff --git a/common/lib/gterm.c b/common/lib/gterm.c
index f465d81c..cb262be5 100644
--- a/common/lib/gterm.c
+++ b/common/lib/gterm.c
@@ -682,6 +682,11 @@ bool gterm_init(struct fb_info **_fbs, size_t *_fbs_count,
         if ((f = uri_open(menu_font)) == NULL) {
             print("menu: Could not open font file.\n");
         } else {
+            if (font_size > f->size) {
+                print("Font size too large for provided font file. Not loading.\n");
+                fclose(f);
+                goto no_load_font;
+            }
             fread(f, font, 0, font_size);
             if (menu_font_size != NULL) {
                 font_width = tmp_font_width;
tab: 248 wrap: offon