From e42952469dadfb3535633c66c881050ac128703c Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 5 Oct 2026 17:05:14 -0400 Subject: fix: gather verbs, walk oom, admin path bypass, roulette refund --- internal/net/conn.go | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'internal/net/conn.go') diff --git a/internal/net/conn.go b/internal/net/conn.go index 4aa4db4..ca40354 100644 --- a/internal/net/conn.go +++ b/internal/net/conn.go @@ -165,23 +165,29 @@ func stripIAC(s string) string { i := 0 iacSE := []byte{iac, se} for i < len(b) { - if b[i] == iac && i+2 < len(b) { - if b[i+1] == sb { - end := bytes.Index(b[i+2:], iacSE) - if end >= 0 { - i += end + 4 - continue - } - } - i += 3 + if b[i] != iac { + out = append(out, b[i]) + i++ continue } - if b[i] == iac { - i++ + // IAC begins a telnet command. If the line ends mid-command, drop the + // remainder: leaking the option byte into player input would corrupt + // the command/password with a stray non-UTF-8 byte. + if i+1 >= len(b) { + break + } + if b[i+1] == sb { + end := bytes.Index(b[i+2:], iacSE) + if end < 0 { + break + } + i += end + 4 continue } - out = append(out, b[i]) - i++ + i += 3 + if i > len(b) { + i = len(b) + } } return string(out) } -- cgit v1.2.3