Author: emaste
Date: Wed Jun  5 15:23:48 2019
New Revision: 348692
URL: https://svnweb.freebsd.org/changeset/base/348692

Log:
  vtfontcvt: exit on error if the input font has too many glyphs
  
  The kernel has a limit of 131072 glyphs in a font; add the same check to
  vtfontcvt so that we won't create a font file that the kernel will not
  load.
  
  PR:           205707
  Submitted by: Dmitry Wagin
  MFC after:    2 weeks

Modified:
  head/usr.bin/vtfontcvt/vtfontcvt.c

Modified: head/usr.bin/vtfontcvt/vtfontcvt.c
==============================================================================
--- head/usr.bin/vtfontcvt/vtfontcvt.c  Wed Jun  5 14:23:10 2019        
(r348691)
+++ head/usr.bin/vtfontcvt/vtfontcvt.c  Wed Jun  5 15:23:48 2019        
(r348692)
@@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$");
 #define VFNT_MAP_NORMAL_RH 1
 #define VFNT_MAP_BOLD 2
 #define VFNT_MAP_BOLD_RH 3
+#define VFNT_MAXGLYPHS 131072
 #define VFNT_MAXDIMENSION 128
 
 static unsigned int width = 8, wbytes, height = 16;
@@ -184,6 +185,8 @@ add_glyph(const uint8_t *bytes, unsigned int map_idx, 
        SLIST_INSERT_HEAD(&glyph_hash[hash], gl, g_hash);
 
        glyph_unique++;
+       if (glyph_unique > VFNT_MAXGLYPHS)
+               errx(1, "too many glyphs (%u)", glyph_unique);
        return (gl);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to