From a47060813b4ee37896db41eb2a449a6c066086ee Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Wed, 22 May 2024 07:50:42 -0700 Subject: [PATCH] [sock] flush / handle lines during input handling when a telnet SB (renegotation) is received This is needed to properly keep GMCP/ATCP handling inline against the incoming socket data lines. Otherwise the SB attributes get handled first whilst the normal data is queued into the line buffer, and then the line buffer is handled at the end. I don't like doing the socket flush here though. Ugh. --- src/socket.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/socket.c b/src/socket.c index d86b79e..6210822 100644 --- a/src/socket.c +++ b/src/socket.c @@ -3530,6 +3530,24 @@ static int handle_socket_input(const char *simbuffer, int simlen, const char *en continue; /* avoid non-telnet processing */ } else if (xsock->fsastate == TN_SB) { + /* + * Flush existing data before handling subnegotiation. + * + * This is needed for the handful of situations where + * things like GMCP/ATCP messages happen to be wrapping + * the incoming text lines rather than a purely out of + * band notification. + * + * Ideally the server would send an EOR or GA here, + * but MUDs use that to terminate the prompt line. + */ +#if WIDECHAR + inbound_decode_str(xsock->buffer, incomingposttelnet, + incomingFSM, 0); +#endif + handle_socket_input_queue_lines(xsock); + flushxsock(); + if (xsock->subbuffer->len > RECEIVELIMIT) { /* It shouldn't take this long; server is broken. Abort. */ SStringcat(xsock->buffer, CS(xsock->subbuffer));