telnetd: ifdef out a buggy error handling code path
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 13 Oct 2016 14:17:06 +0000 (16:17 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 13 Oct 2016 14:17:06 +0000 (16:17 +0200)
Here, not handling the error is would just eat one input 0xff char.
Correct handling would need even more corner case handling,
as-is buggy handling corrupts the buffer.
Since we just been told by kernel that pty is ready,
EAGAIN should not be happening here anyway.

function                                             old     new   delta
telnetd_main                                        1798    1785     -13

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
networking/telnetd.c

index 1de3abcc77510b22786ac8d5b46309afbbd0e501..303ef1be75bb9e0fbd4cc59b5f635215c2b0413c 100644 (file)
@@ -192,8 +192,16 @@ safe_write_to_pty_decode_iac(struct tsession *ts)
                /* Literal 255 (emacs M-DEL) */
                //bb_error_msg("255!");
                rc = safe_write(ts->ptyfd, &buf[1], 1);
+               /*
+                * If we went through buffered_IAC_for_pty==1 path,
+                * bailing out on error like below messes up the buffer.
+                * EAGAIN is highly unlikely here, other errors will be
+                * repeated on next write, let's just skip error check.
+                */
+#if 0
                if (rc <= 0)
                        return rc;
+#endif
                rc = 2;
                goto update_and_return;
        }