This is an automated email from Gerrit.

Tarek BOCHKATI (tarek.bouchk...@gmail.com) just uploaded a new patch set to 
Gerrit, which you can find at http://openocd.zylin.com/6441

-- gerrit

commit d221c8b539461f161b1d6eb75b7e9d4362cd84aa
Author: Tarek BOCHKATI <tarek.bouchk...@gmail.com>
Date:   Wed Aug 18 19:55:48 2021 +0100

    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.bouchk...@gmail.com>

diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c
index f7b3f64..36b017c 100644
--- a/src/server/telnet_server.c
+++ b/src/server/telnet_server.c
@@ -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;

-- 

Reply via email to