server/telnet: enhance telnet_move_cursor 41/6441/2
authorTarek BOCHKATI <tarek.bouchkati@gmail.com>
Wed, 18 Aug 2021 18:55:48 +0000 (19:55 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Mon, 30 Aug 2021 13:54:06 +0000 (13:54 +0000)
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>
src/server/telnet_server.c

index f7b3f6449bbfda33c3daa894a1ad963f7ccdb052..36b017c58ebb2916d81ad42b7ca0e5b6c5eca4e4 100644 (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;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)