Skip to content

Commit

Permalink
[sock] flush / handle lines during input handling when a telnet SB (r…
Browse files Browse the repository at this point in the history
…enegotation) is received (#84)

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.

Co-authored-by: Adrian Chadd <[email protected]>
Co-authored-by: Karol Lassak <[email protected]>
  • Loading branch information
3 people authored May 26, 2024
1 parent b538ce4 commit 69e9206
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 69e9206

Please sign in to comment.