Deleted Added
full compact
31c31
< __FBSDID("$FreeBSD: head/sys/dev/vt/vt_font.c 256145 2013-10-08 12:40:04Z ray $");
---
> __FBSDID("$FreeBSD: stable/10/sys/dev/vt/vt_font.c 262861 2014-03-06 18:30:56Z jhb $");
44,45c44,45
< #define VTFONT_MAXMAPPINGS 1024
< #define VTFONT_MAXGLYPHSIZE 262144
---
> #define VTFONT_MAXMAPPINGS 8192
> #define VTFONT_MAXGLYPHSIZE 1048576
88a89,90
> unsigned int normal_map;
> unsigned int bold_map;
89a92,96
> /*
> * No support for printing right hand sides for CJK fullwidth
> * characters. Simply print a space and assume that the left
> * hand side describes the entire character.
> */
90a98,105
> if (TCHAR_FORMAT(c) & TF_CJK_RIGHT) {
> normal_map = VFNT_MAP_NORMAL_RIGHT;
> bold_map = VFNT_MAP_BOLD_RIGHT;
> } else {
> normal_map = VFNT_MAP_NORMAL;
> bold_map = VFNT_MAP_BOLD;
> }
>
92c107,108
< dst = vtfont_bisearch(vf->vf_bold, vf->vf_bold_length, src);
---
> dst = vtfont_bisearch(vf->vf_map[bold_map],
> vf->vf_map_count[bold_map], src);
96c112,113
< dst = vtfont_bisearch(vf->vf_normal, vf->vf_normal_length, src);
---
> dst = vtfont_bisearch(vf->vf_map[normal_map],
> vf->vf_map_count[normal_map], src);
113a131
> unsigned int i;
116,117c134,135
< free(vf->vf_normal, M_VTFONT);
< free(vf->vf_bold, M_VTFONT);
---
> for (i = 0; i < VFNT_MAPS; i++)
> free(vf->vf_map[i], M_VTFONT);
125c143
< unsigned int nglyphs)
---
> unsigned int glyph_count)
136,137c154,155
< if (vfm[i].vfm_dst >= nglyphs ||
< vfm[i].vfm_dst + vfm[i].vfm_len >= nglyphs)
---
> if (vfm[i].vfm_dst >= glyph_count ||
> vfm[i].vfm_dst + vfm[i].vfm_len >= glyph_count)
148c166
< size_t glyphsize;
---
> size_t glyphsize, mapsize;
150a169
> unsigned int i;
159,160c178,180
< if (f->nnormal > VTFONT_MAXMAPPINGS || f->nbold > VTFONT_MAXMAPPINGS)
< return (E2BIG);
---
> for (i = 0; i < VFNT_MAPS; i++)
> if (f->map_count[i] > VTFONT_MAXMAPPINGS)
> return (E2BIG);
163c183
< if (f->nglyphs < 1)
---
> if (f->glyph_count < 1)
166c186
< glyphsize = howmany(f->width, 8) * f->height * f->nglyphs;
---
> glyphsize = howmany(f->width, 8) * f->height * f->glyph_count;
171,175c191
< vf = malloc(sizeof *vf, M_VTFONT, M_WAITOK);
< vf->vf_normal = malloc(f->nnormal * sizeof(struct vt_font_map),
< M_VTFONT, M_WAITOK);
< vf->vf_bold = malloc(f->nbold * sizeof(struct vt_font_map),
< M_VTFONT, M_WAITOK);
---
> vf = malloc(sizeof *vf, M_VTFONT, M_WAITOK | M_ZERO);
179,180d194
< vf->vf_normal_length = f->nnormal;
< vf->vf_bold_length = f->nbold;
183,191c197,213
< /* Copy in data. */
< error = copyin(f->normal, vf->vf_normal,
< vf->vf_normal_length * sizeof(struct vt_font_map));
< if (error)
< goto bad;
< error = copyin(f->bold, vf->vf_bold,
< vf->vf_bold_length * sizeof(struct vt_font_map));
< if (error)
< goto bad;
---
> /* Allocate, copy in, and validate mappings. */
> for (i = 0; i < VFNT_MAPS; i++) {
> vf->vf_map_count[i] = f->map_count[i];
> if (f->map_count[i] == 0)
> continue;
> mapsize = f->map_count[i] * sizeof(struct vt_font_map);
> vf->vf_map[i] = malloc(mapsize, M_VTFONT, M_WAITOK);
> error = copyin(f->map[i], vf->vf_map[i], mapsize);
> if (error)
> goto bad;
> error = vtfont_validate_map(vf->vf_map[i], vf->vf_map_count[i],
> f->glyph_count);
> if (error)
> goto bad;
> }
>
> /* Copy in glyph data. */
196,205d217
< /* Validate mappings. */
< error = vtfont_validate_map(vf->vf_normal, vf->vf_normal_length,
< f->nglyphs);
< if (error)
< goto bad;
< error = vtfont_validate_map(vf->vf_bold, vf->vf_bold_length,
< f->nglyphs);
< if (error)
< goto bad;
<