From adb59fe3411e34cf43d345dec39aef27f7564f75 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 5 Aug 2011 14:39:11 -0700 Subject: [PATCH] Proper handling of cursor reset. Clear argv[] when done. --- protocols/ssh/src/ssh_terminal_handlers.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/protocols/ssh/src/ssh_terminal_handlers.c b/protocols/ssh/src/ssh_terminal_handlers.c index 875f3185..b696e241 100644 --- a/protocols/ssh/src/ssh_terminal_handlers.c +++ b/protocols/ssh/src/ssh_terminal_handlers.c @@ -151,7 +151,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { /* CSI function arguments */ static int argc = 0; - static int argv[16]; + static int argv[16] = {0}; /* Argument building counter and buffer */ static int argv_length = 0; @@ -173,7 +173,7 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { /* Any non-digit stops the parameter, and possibly the sequence */ else { - int i; + int i, row, col; /* At most 16 parameters */ if (argc < 16) { @@ -259,8 +259,12 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { /* H: Move cursor */ case 'H': - term->cursor_row = argv[0] - 1; - term->cursor_col = argv[1] - 1; + + row = argv[0]; if (row != 0) row--; + col = argv[1]; if (col != 0) col--; + + term->cursor_row = row; + term->cursor_col = col; break; /* J: Erase display */ @@ -326,6 +330,10 @@ int ssh_guac_terminal_csi(ssh_guac_terminal* term, char c) { if (c != ';') { term->char_handler = ssh_guac_terminal_echo; + /* Reset parameters */ + for (i=0; i