server/telnet: enhance telnet_move_cursor

instrument the telnet_move_cursor to detect when there is no change
of cursor position and if the requested new position is out of bounds.

Change-Id: I24da877e538a458da6d2f8ddc2a681eee404d2cb
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6441
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tarek BOCHKATI 2021-08-18 19:55:48 +01:00 committed by Antonio Borneo
parent 70cd395f3f
commit 9a9e9e2c66
1 changed files with 6 additions and 2 deletions

View File

@ -352,10 +352,14 @@ static int telnet_history_print(struct connection *connection)
static void telnet_move_cursor(struct connection *connection, size_t pos)
{
struct telnet_connection *tc;
struct telnet_connection *tc = connection->priv;
size_t tmp;
tc = connection->priv;
if (pos == tc->line_cursor) /* nothing to do */
return;
if (pos > tc->line_size) /* out of bounds */
return;
if (pos < tc->line_cursor) {
tmp = tc->line_cursor - pos;