Bugzilla – Attachment 2726 Details for
Bug 2478
Escape sequences (starting with ~) don't work when remote shell is BusyBox ash
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch v2
0001-ANSI-terminal-escape-sequences-do-not-affect-process.patch (text/plain), 3.25 KB, created by
Alex Dowad
on 2015-10-13 17:22:59 AEDT
(
hide
)
Description:
Patch v2
Filename:
MIME Type:
Creator:
Alex Dowad
Created:
2015-10-13 17:22:59 AEDT
Size:
3.25 KB
patch
obsolete
>From c4f36769ef97e5159cbd69eba4057bfab88da667 Mon Sep 17 00:00:00 2001 >From: Alex Dowad <alexinbeijing@gmail.com> >Date: Mon, 12 Oct 2015 20:38:00 +0200 >Subject: [PATCH] ANSI terminal escape sequences do not affect processing of > SSH escapes > >Even when the user has not pressed a key, ANSI-compatible terminal emulators >can send escape sequences to ssh's stdin at any time. For example, any time that >the server sends an "<ESC>[6n" (query cursor position) sequence, an ANSI-compatible >terminal will send back "<ESC>[<ROW>;<COLUMN>R". ssh sees these escape sequences >just as if they were characters typed in by the user. This causes problems if the >user is attempting to type an SSH escape sequence, starting with "<ENTER>~". > >Therefore, when scanning user input for SSH escape sequences, skip over any >ANSI terminal control sequences which appear in the input. >--- > clientloop.c | 24 ++++++++++++++++++------ > 1 file changed, 18 insertions(+), 6 deletions(-) > >diff --git a/clientloop.c b/clientloop.c >index 87ceb3d..c45c523 100644 >--- a/clientloop.c >+++ b/clientloop.c >@@ -154,6 +154,7 @@ volatile sig_atomic_t quit_pending; /* Set non-zero to quit the loop. */ > static int escape_char1; /* Escape character. (proto1 only) */ > static int escape_pending1; /* Last character was an escape (proto1 only) */ > static int last_was_cr; /* Last character was a newline. */ >+static int last_was_ansi; /* Last character was part of an ANSI escape. */ > static int exit_status; /* Used to store the command exit status. */ > static int stdin_eof; /* EOF has been encountered on stderr. */ > static Buffer stdin_buffer; /* Buffer for stdin data. */ >@@ -1096,7 +1097,14 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr, > /* Get one character at a time. */ > ch = buf[i]; > >- if (*escape_pendingp) { >+ /* ANSI terminal escape sequences may appear anywhere in input stream. */ >+ /* They do not affect our processing of our own escapes. */ >+ if (ch == 0x1B) { >+ last_was_ansi = 1; >+ } else if (last_was_ansi) { >+ if (ch != '[' && ch != ';' && !isdigit(ch)) >+ last_was_ansi = 0; >+ } else if (*escape_pendingp) { > /* We have previously seen an escape character. */ > /* Clear the flag now. */ > *escape_pendingp = 0; >@@ -1276,6 +1284,10 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr, > buffer_put_char(bin, escape_char); > bytes++; > } >+ >+ /* Record whether escaped character was a newline. */ >+ last_was_cr = (ch == '\r' || ch == '\n'); >+ > /* Escaped characters fall through here */ > break; > } >@@ -1292,13 +1304,12 @@ process_escapes(Channel *c, Buffer *bin, Buffer *bout, Buffer *berr, > *escape_pendingp = 1; > continue; > } >+ >+ /* It wasn't an escape, was it a newline? */ >+ last_was_cr = (ch == '\r' || ch == '\n'); > } > >- /* >- * Normal character. Record whether it was a newline, >- * and append it to the buffer. >- */ >- last_was_cr = (ch == '\r' || ch == '\n'); >+ /* Normal character. Append it to the buffer. */ > buffer_put_char(bin, ch); > bytes++; > } >@@ -1495,6 +1506,7 @@ client_loop(int have_pty, int escape_char_arg, int ssh2_chan_id) > /* Initialize variables. */ > escape_pending1 = 0; > last_was_cr = 1; >+ last_was_ansi = 0; > exit_status = -1; > stdin_eof = 0; > buffer_high = 64 * 1024; >-- >2.0.0.GIT >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 2478
:
2725
| 2726