1 From bc5dc7af74e6fa1c70aa4bbb1e482fd0c3663af3 Mon Sep 17 00:00:00 2001
2 From: Mats Erik Andersson <gnu@gisladisker.se>
3 Date: Sat, 15 Aug 2015 20:56:26 +0200
4 Subject: [PATCH 11/60] telnetd: Premature connection closure.
6 A change, part of 0b7e8687, but secondary to its
7 intention, turned out to cause service rejects during
8 conditions akin to connection flooding. Revert this
9 particular part to gain established, good behaviour
11 Reported in `bug-inetutils/2015-07/msg00006.html'.
13 ChangeLog | 18 ++++++++++++++++++
14 telnetd/telnetd.c | 8 +++++++-
15 telnetd/utility.c | 8 ++++++++
16 3 files changed, 33 insertions(+), 1 deletion(-)
18 diff --git a/ChangeLog b/ChangeLog
19 index 73b281b9..03bb8a78 100644
23 +2015-08-15 Mats Erik Andersson <gnu@gisladisker.se>
25 + telnetd: Premature connection closure.
26 + When many connections are attempted in quick succession,
27 + a substantial number of them are cancelled. This does not
28 + appear for manual use cases, but for contrived automated
29 + set-ups. The cause seems to be a change in the evaluation
30 + of pty_read(), which was done to coincide with the condition
31 + in use by the original BSD implementation. Issue reported and
32 + suggested by Chris Severance in
33 + http://lists.gnu.org/archive/html/bug-inetutils/2015-07/msg00006.html
35 + * telnetd/telnetd.c (telnetd_run): Break the loop only by the
36 + stronger condition `pty_read() < 0', i.e., only on non-masked
37 + read errors. This reverts a change introduced in 2015-03-15.
38 + * telnetd/utility.c (pty_read): Add a comment that the read
39 + errors EWOULDBLOCK, EAGAIN, and EIO are treated specially.
41 2015-08-07 Mats Erik Andersson <gnu@gisladisker.se>
43 ifconfig: Statistics for BSD systems.
44 diff --git a/telnetd/telnetd.c b/telnetd/telnetd.c
45 index faecc072..0bf102ac 100644
46 --- a/telnetd/telnetd.c
47 +++ b/telnetd/telnetd.c
48 @@ -662,7 +662,13 @@ telnetd_run (void)
49 if (FD_ISSET (pty, &ibits))
51 /* Something to read from the pty... */
52 - if (pty_read () <= 0)
54 + /* Observe that pty_read() is masking a few select
55 + * read errors with the return value 0. Let them
56 + * pass for further manipulation. Issue reported in
57 + * http://lists.gnu.org/archive/html/bug-inetutils/2015-07/msg00006.html
59 + if (pty_read () < 0)
62 /* The first byte is now TIOCPKT data. Peek at it. */
63 diff --git a/telnetd/utility.c b/telnetd/utility.c
64 index e7ffb8ed..e493dff2 100644
65 --- a/telnetd/utility.c
66 +++ b/telnetd/utility.c
67 @@ -372,6 +372,14 @@ pty_input_putback (const char *str, size_t len)
73 + * Read errors EWOULDBLOCK, EAGAIN, and EIO are
74 + * tweeked into reporting zero bytes input.
75 + * In particular, EIO is known to appear when
76 + * reading off the master side, before having
77 + * an active slave side.
83 2.26.0.292.g33ef6b2f38