BBS:      TELESC.NET.BR
Assunto:  src/sbbs3/con_out.cpp
De:       Deuc¨
Data:     Sun, 15 Mar 2026 20:35:47 -0700
-----------------------------------------------------------
https://gitlab.synchro.net/main/sbbs/-/commit/15fde4bd32f361dd5a887f08
Modified Files:
	src/sbbs3/con_out.cpp
Log Message:
Fix infinite loop in cp437_out() TAB expansion

cp437_out() expands TAB (0x09) by calling term_out(' ') in a loop,
polling term->column to determine when to stop. When the ANSI parser
(parse_output) is mid-sequence  e.g. because binary data containing
ESC was passed through rputs()/console.write()  the space is consumed
by the parser without advancing term->column, causing an infinite loop
that sends spaces forever and pegs the CPU at 100%.

Prior to the Terminal class refactor (374282bf81), TAB expansion lived
in outchar() and used outcom(' ') with manual column++ tracking,
which was immune to ANSI parser state. The refactor moved it to
cp437_out() and switched to term_out(), introducing the dependency on
parse_output() advancing the column.

Fix: compute the target column and space count upfront from the current
column and tabstop, then loop a fixed number of iterations regardless
of whether term->column actually advances. Also guard against
tabstop == 0 (would be division by zero in the original modulo check).

Found by ANSI fuzz testing (termtest.js) sending random byte streams
containing ESC followed by TAB.

Co-Authored-By: Claude Opus 4.6 
n
---
  mSynchronetn  hgVertrauen n hHome of Synchronet n gh[vert/cvs/bbs].synchro.net

-----------------------------------------------------------
[Voltar]