← Commit list

8738c3102

Denys Vlasenko
Denys Vlasenko
2026-02-22
SUCCESS Duration: 145s

Subject

telnetd: fix handshake: had one wrong, but harmless element

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
gcc -Wp,-MD,applets/.usage.d -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer      -Iinclude -Iinclude -o applets/usage applets/usage.c

Build Log

(log yok)

Commit Diff GitHub →

networking/telnet.txt+1 -1
@@ -2,7 +2,7 @@
// IAC SE (240) End of subnegotiation parameters
// IAC NOP (241) No operation
// IAC DM (242) Data Mark (used with TCP urgent pointer)
-// IAC BRK (243) Break (simulate serial line break) - perhaps tcsendbreak(master_ptyfd, 0) [untested]?
+// IAC BRK (243) Break (simulate serial line break) - perhaps tcsendbreak(master_ptyfd)? [untested]
// IAC IP (244) Interrupt Process ("send SIGINT to foreground process group a-la ^C")
// IAC AO (245) Abort Output
// IAC AYT (246) Are You There
networking/telnetd.c+14 -6
@@ -866,13 +866,21 @@ static void make_new_session(ioloop_state_t *io, int sockrd)
* stuff that requires char-by-char support. */
{
static const char iacs_to_send[] ALIGN1 = {
- IAC, DO, TELOPT_ECHO,
- IAC, DO, TELOPT_NAWS,
- /* This requires telnetd.ctrlSQ.patch (incomplete) */
- /*IAC, DO, TELOPT_LFLOW,*/
- IAC, WILL, TELOPT_ECHO,
- IAC, WILL, TELOPT_SGA
+ IAC, WILL, TELOPT_ECHO, // "I will echo your chars"
+ // (Not really, _we_ won't - our programs in pty usually
+ // handle that. In practice, this says: "do not echo
+ // your user's input chars back to him _on your side_".)
+ IAC, WILL, TELOPT_SGA, // "I assume full-duplex, won't send GA's"
+ //IAC, DO, TELOPT_ECHO, //WRONG: "can you echo my chars to me"??
+ IAC, DO, TELOPT_NAWS, // "can you send me terminal size data?"
+ // This requires telnetd.ctrlSQ.patch (incomplete):
+ //IAC, DO, TELOPT_LFLOW,
};
+//Theoretically, our "WILL X" are requests and should only activate when client responds with "DO X".
+//However, we do not wait/check for "DO"s. Why?
+//There is nothing to "activate" on our side for TELOPT_ECHO.
+//For TELOPT_SGA, we don't even have code to support sending/understandig GAs,
+//so SGA is "always activated".
/* Just stuff it into TCP stream! (no error check...) */
safe_write(sockwr, iacs_to_send, sizeof(iacs_to_send));
}