From 4267d8d7c265b8b74a079dc1030ec5b9f7ae9a60 Mon Sep 17 00:00:00 2001 From: sporteka Date: Thu, 23 Jul 2026 04:36:18 +0300 Subject: [PATCH] Fix buffer overflow in get_dpi(): alloca(strlen(p)) -> alloca(strlen(p) + 1) alloca(strlen(p)) does not account for the null terminator. strcpy writes one byte past the allocated buffer, causing a "buffer overflow detected" abort on startup. Closes #171 --- uitoolkit/libtype/ui_font_ft.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/uitoolkit/libtype/ui_font_ft.c b/uitoolkit/libtype/ui_font_ft.c index 79d39674..efafbbb1 100644 --- a/uitoolkit/libtype/ui_font_ft.c +++ b/uitoolkit/libtype/ui_font_ft.c @@ -1281,7 +1281,7 @@ static double get_dpi(ui_font_t *font) { const char *p = XResourceManagerString(font->display); char *rs; - if ((rs = alloca(strlen(p))) != NULL) { + if ((rs = alloca(strlen(p) + 1)) != NULL) { strcpy(rs, p); while ((p = bl_str_sep(&rs, "\n")) != NULL) {