Skip to content

Commit 6d7b439

Browse files
natoscottclaude
andcommitted
Guard title truncation against narrow terminal widths
Prevent stack buffer underflow in InfoScreen_drawTitled() when the terminal width is 2 columns or fewer, where COLS - 3 produces a negative index into the title VLA. Closes: GHSA-6f53-xw2h-ww59 Reported-by: Michał Majchrowicz (AFINE Team) Reported-by: Marcin Wyczechowski (AFINE Team) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 544880e commit 6d7b439

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

InfoScreen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ void InfoScreen_drawTitled(InfoScreen* this, const char* fmt, ...) {
5555
int len = vsnprintf(title, sizeof(title), fmt, ap);
5656
va_end(ap);
5757

58-
if (len > COLS) {
58+
if (len > COLS && COLS >= 3) {
5959
memset(&title[COLS - 3], '.', 3);
6060
}
6161

0 commit comments

Comments
 (0)