mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
[st][patch][ligatures] fix potential buffer overflow in shaping code ref. https://git.suckless.org/sites/commit/05a0d9b6bf500a7b2955c4299a1912eb302ce40b.html
This commit is contained in:
parent
ff557169e4
commit
ac9f541965
17
hb.c
17
hb.c
@ -1,12 +1,16 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <X11/Xft/Xft.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <X11/Xft/Xft.h>
|
||||||
|
#include <X11/cursorfont.h>
|
||||||
#include <hb.h>
|
#include <hb.h>
|
||||||
#include <hb-ft.h>
|
#include <hb-ft.h>
|
||||||
|
|
||||||
#include "st.h"
|
#include "st.h"
|
||||||
|
|
||||||
|
#define FEATURE(c1,c2,c3,c4) { .tag = HB_TAG(c1,c2,c3,c4), .value = 1, .start = HB_FEATURE_GLOBAL_START, .end = HB_FEATURE_GLOBAL_END }
|
||||||
|
|
||||||
void hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length);
|
void hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoints, int start, int length);
|
||||||
hb_font_t *hbfindfont(XftFont *match);
|
hb_font_t *hbfindfont(XftFont *match);
|
||||||
|
|
||||||
@ -18,6 +22,13 @@ typedef struct {
|
|||||||
static int hbfontslen = 0;
|
static int hbfontslen = 0;
|
||||||
static HbFontMatch *hbfontcache = NULL;
|
static HbFontMatch *hbfontcache = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Poplulate the array with a list of font features, wrapped in FEATURE macro,
|
||||||
|
* e. g.
|
||||||
|
* FEATURE('c', 'a', 'l', 't'), FEATURE('d', 'l', 'i', 'g')
|
||||||
|
*/
|
||||||
|
hb_feature_t features[] = { };
|
||||||
|
|
||||||
void
|
void
|
||||||
hbunloadfonts()
|
hbunloadfonts()
|
||||||
{
|
{
|
||||||
@ -59,7 +70,7 @@ void
|
|||||||
hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y)
|
hbtransform(XftGlyphFontSpec *specs, const Glyph *glyphs, size_t len, int x, int y)
|
||||||
{
|
{
|
||||||
int start = 0, length = 1, gstart = 0;
|
int start = 0, length = 1, gstart = 0;
|
||||||
hb_codepoint_t *codepoints = calloc(len, sizeof(hb_codepoint_t));
|
hb_codepoint_t *codepoints = calloc((unsigned int)len, sizeof(hb_codepoint_t));
|
||||||
|
|
||||||
for (int idx = 1, specidx = 1; idx < len; idx++) {
|
for (int idx = 1, specidx = 1; idx < len; idx++) {
|
||||||
if (glyphs[idx].mode & ATTR_WDUMMY) {
|
if (glyphs[idx].mode & ATTR_WDUMMY) {
|
||||||
@ -127,7 +138,7 @@ hbtransformsegment(XftFont *xfont, const Glyph *string, hb_codepoint_t *codepoin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Shape the segment. */
|
/* Shape the segment. */
|
||||||
hb_shape(font, buffer, NULL, 0);
|
hb_shape(font, buffer, features, sizeof(features)/sizeof(hb_feature_t));
|
||||||
|
|
||||||
/* Get new glyph info. */
|
/* Get new glyph info. */
|
||||||
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
|
hb_glyph_info_t *info = hb_buffer_get_glyph_infos(buffer, NULL);
|
||||||
|
Loading…
Reference in New Issue
Block a user