From 0a78d39dd2e3389140dff826a5d52b23fed6248b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Tue, 29 Oct 2024 15:07:45 -0400 Subject: [PATCH] Fix handling of broken CRLF pairs in RIP mode If telnet binary mode is enabled (the new default), and a CR and LF come in on separate recv() calls, the RIP parser would stop at the CR, and pass the LF back to the ANSI parser. Ah, dura-bbs.net, always pushing the limits. --- src/syncterm/ripper.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/syncterm/ripper.c b/src/syncterm/ripper.c index 056366919f..1ec895bee6 100644 --- a/src/syncterm/ripper.c +++ b/src/syncterm/ripper.c @@ -86,7 +86,7 @@ enum rip_state { // Back to normal state definitions -/*23*/, +/*18*/, RIP_STATE_CR // Got a CR , RIP_STATE_ESC // Got an ESC @@ -15604,7 +15604,10 @@ handle_rip_line(BYTE *buf, unsigned *blen, unsigned *pos, size_t *rip_start, uns remainder = *blen - *pos - 1; } else { - remove = 0; + if ((*blen > 0) && (rip.state == RIP_STATE_CR) && (buf[0] == '\n')) + remove = 1; + else + remove = 0; remainder = *blen; } if (ns == RIP_STATE_FLUSHING) { -- GitLab