diff options
| author | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-17 11:54:35 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-09-17 11:54:35 +0200 |
| commit | 0ffd63ca9a46d1e9112e12702e4337195eade25d (patch) | |
| tree | 30730bb09bcedf3fe869b2620a480bc7f3740af8 | |
| parent | 57f07bfcb276777f9ea85df7d09ae005a0231464 (diff) | |
| download | busybox-w32-0ffd63ca9a46d1e9112e12702e4337195eade25d.tar.gz busybox-w32-0ffd63ca9a46d1e9112e12702e4337195eade25d.tar.bz2 busybox-w32-0ffd63ca9a46d1e9112e12702e4337195eade25d.zip | |
telnet: convert Enter -> CR LF in line mode too
function old new delta
handle_net_output 87 98 +11
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
| -rw-r--r-- | networking/telnet.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/networking/telnet.c b/networking/telnet.c index b700fbed9..58a691916 100644 --- a/networking/telnet.c +++ b/networking/telnet.c | |||
| @@ -187,27 +187,34 @@ static void con_escape(void) | |||
| 187 | static void handle_net_output(int len) | 187 | static void handle_net_output(int len) |
| 188 | { | 188 | { |
| 189 | byte outbuf[2 * DATABUFSIZE]; | 189 | byte outbuf[2 * DATABUFSIZE]; |
| 190 | byte *p = (byte*)G.buf; | 190 | byte *dst = outbuf; |
| 191 | int j = 0; | 191 | byte *src = (byte*)G.buf; |
| 192 | byte *end = src + len; | ||
| 192 | 193 | ||
| 193 | for (; len > 0; len--, p++) { | 194 | while (src < end) { |
| 194 | byte c = *p; | 195 | byte c = *src++; |
| 195 | if (c == 0x1d) { | 196 | if (c == 0x1d) { |
| 196 | con_escape(); | 197 | con_escape(); |
| 197 | return; | 198 | return; |
| 198 | } | 199 | } |
| 199 | outbuf[j++] = c; | 200 | *dst = c; |
| 200 | if (c == IAC) | 201 | if (c == IAC) |
| 201 | outbuf[j++] = c; /* IAC -> IAC IAC */ | 202 | *++dst = c; /* IAC -> IAC IAC */ |
| 202 | else if (c == '\r') | 203 | else |
| 203 | /* See RFC 1123 3.3.1 Telnet End-of-Line Convention. | 204 | if (c == '\r' || c == '\n') { |
| 205 | /* Enter key sends '\r' in raw mode and '\n' in cooked one. | ||
| 206 | * | ||
| 207 | * See RFC 1123 3.3.1 Telnet End-of-Line Convention. | ||
| 204 | * Using CR LF instead of other allowed possibilities | 208 | * Using CR LF instead of other allowed possibilities |
| 205 | * like CR NUL - easier to talk to HTTP/SMTP servers. | 209 | * like CR NUL - easier to talk to HTTP/SMTP servers. |
| 206 | */ | 210 | */ |
| 207 | outbuf[j++] = '\n'; /* CR -> CR LF */ | 211 | *dst = '\r'; /* Enter -> CR LF */ |
| 212 | *++dst = '\n'; | ||
| 213 | } | ||
| 214 | dst++; | ||
| 208 | } | 215 | } |
| 209 | if (j > 0) | 216 | if (dst - outbuf != 0) |
| 210 | full_write(netfd, outbuf, j); | 217 | full_write(netfd, outbuf, dst - outbuf); |
| 211 | } | 218 | } |
| 212 | 219 | ||
| 213 | static void handle_net_input(int len) | 220 | static void handle_net_input(int len) |
