Skip to content

Commit 64fce83

Browse files
committed
Prevent another integer overflow in drawScreenTab()
Specifically there's an integer overflow potential in (x + 1 + SCREEN_TAB_COLUMN_GAP). Fix it with a better clamping logic. Follow-up of commit e9e8001 Supersedes #1984. Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
1 parent e92007b commit 64fce83

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

ScreenManager.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,11 @@ static inline bool drawTab(const int* y, int* x, int l, const char* name, bool c
185185
return false;
186186
attrset(CRT_colors[cur ? SCREENS_CUR_BORDER : SCREENS_OTH_BORDER]);
187187
mvaddch(*y, *x, ']');
188-
*x += 1 + SCREEN_TAB_COLUMN_GAP;
189-
if (*x >= l)
188+
if (*x >= l - (1 + SCREEN_TAB_COLUMN_GAP)) {
189+
*x = l;
190190
return false;
191+
}
192+
*x += 1 + SCREEN_TAB_COLUMN_GAP;
191193
return true;
192194
}
193195

0 commit comments

Comments
 (0)