pango: passing -fn option could lead to segfault due to writing out of bounds

This commit is contained in:
bakkeby 2024-05-17 21:42:30 +02:00
parent 4f71e5593e
commit 9ef1b3c317
4 changed files with 4 additions and 4 deletions

View File

@ -30,7 +30,7 @@ static int restrict_return = 0; /* -1 option; if 1, disables shift-r
#endif // RESTRICT_RETURN_PATCH
/* -fn option overrides fonts[0]; default X11 font or font set */
#if PANGO_PATCH
static char font[] = "monospace 10";
static char *font = "monospace 10";
#else
#if XRESOURCES_PATCH
static char *fonts[] =

View File

@ -2054,7 +2054,7 @@ main(int argc, char *argv[])
prompt = argv[++i];
else if (!strcmp(argv[i], "-fn")) /* font or font set */
#if PANGO_PATCH
strcpy(font, argv[++i]);
font = argv[++i];
#else
fonts[0] = argv[++i];
#endif // PANGO_PATCH

2
drw.c
View File

@ -234,7 +234,7 @@ xfont_free(Fnt *font)
#if PANGO_PATCH
Fnt*
drw_font_create(Drw* drw, const char font[])
drw_font_create(Drw* drw, const char *font)
{
Fnt *fnt = NULL;

2
drw.h
View File

@ -55,7 +55,7 @@ void drw_free(Drw *drw);
/* Fnt abstraction */
#if PANGO_PATCH
Fnt *drw_font_create(Drw* drw, const char font[]);
Fnt *drw_font_create(Drw* drw, const char *font);
void drw_font_free(Fnt* set);
unsigned int drw_font_getwidth(Drw *drw, const char *text, Bool markup);
unsigned int drw_fontset_getwidth_clamp(Drw *drw, const char *text, unsigned int n);