fix buffer overflow in update_topl
Buffer overflows could occur when interacting with containers while inputting or outputting many items. This commit ensures topline updates do not exceed buffer limits by checking against TBUFSZ. Issue reported by k21971 on IRC.
This commit is contained in:
+2
-1
@@ -261,7 +261,8 @@ update_topl(const char *bp)
|
||||
n0 = strlen(bp);
|
||||
if ((ttyDisplay->toplin == TOPLINE_NEED_MORE || skip)
|
||||
&& cw->cury == 0
|
||||
&& n0 + (int) strlen(gt.toplines) + 3 < CO - 8 /* room for --More-- */
|
||||
/* room for --More-- */
|
||||
&& n0 + (int) strlen(gt.toplines) + 3 < min(CO - 8, TBUFSZ)
|
||||
&& (notdied = strncmp(bp, "You die", 7)) != 0) {
|
||||
Strcat(gt.toplines, " ");
|
||||
Strcat(gt.toplines, bp);
|
||||
|
||||
Reference in New Issue
Block a user