jcs
/subtext
/amendments
/501
telnet: Handle (ignore) IAC NOP, don't put unhandled IACs in output
jcs made amendment 501 about 1 year ago
--- telnet.c Thu Apr 27 08:01:55 2023
+++ telnet.c Mon May 1 15:14:45 2023
@@ -25,6 +25,7 @@
#include "util.h"
#define SE 240 /* end of sub-negotiation options */
+#define NOP 241 /* no operation */
#define SB 250 /* start of sub-negotiation options */
#define WILL 251 /* confirm willingness to negotiate */
#define WONT 252 /* confirm unwillingness to negotiate */
@@ -482,6 +483,9 @@ telnet_input(struct session *session)
session->ibuf[session->ibuflen++] = c;
node->iac_state = TELNET_IAC_STATE_IDLE;
break;
+ case NOP:
+ node->iac_state = TELNET_IAC_STATE_IDLE;
+ break;
case WILL:
/* client will do something */
node->iac_state = TELNET_IAC_STATE_WILL;
@@ -504,10 +508,8 @@ telnet_input(struct session *session)
node->sb_len = 0;
break;
default:
+ /* unsupported command, ignore it */
node->iac_state = TELNET_IAC_STATE_IDLE;
- /* XXX: what are we supposed to do here? */
- session->ibuf[session->ibuflen++] = IAC;
- session->ibuf[session->ibuflen++] = c;
break;
}
break;