Skip to content

Commit 9c645a2

Browse files
committed
Block arrow keys in sshd server so that it is not passed to shell/cmd or echoed
For now we avoid sending the 4 arrow keys to the shell or echo it to the remote side. as cmd.exe or powershell does not process it correctly in stream output device mode we run win32 sshd server.
1 parent 9f26b75 commit 9c645a2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

channels.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2480,8 +2480,15 @@ channel_input_data(int type, u_int32_t seq, void *ctxt)
24802480
}
24812481
}
24822482
else {
2483+
// avoid sending the 4 arrow keys out to remote for now "ESC[A" ..
2484+
if ( (c->isatty) && (data_len ==3) && (data[0] == '\033') && (data[1] == '[')) {
2485+
if ( ( data[2] == 'A') || (data[2] == 'B') || (data[2] == 'C') || (data[2] == 'D'))
2486+
packet_check_eom();
2487+
return 0;
2488+
}
24832489
buffer_append(&c->output, data, data_len); // it is the sshd server, so pass it on
2484-
if ( c->isatty ) { // we echo the data if it is sshd server and pty interactive mode
2490+
if ( c->isatty ) { // we echo the data if it is sshd server and pty interactive mode
2491+
24852492
if ( (data_len ==1) && (data[0] == '\b') ) {
24862493
if (charinline >0) {
24872494
buffer_append(&c->input, "\b \b", 3); // for backspace, we need to send space and another backspace for visual erase

0 commit comments

Comments
 (0)