diff options
author | Tarek BOCHKATI <tarek.bouchkati@gmail.com> | 2022-05-28 18:45:35 +0100 |
---|---|---|
committer | Antonio Borneo <borneo.antonio@gmail.com> | 2022-06-10 21:55:39 +0000 |
commit | d1b882f2c014258be5397067e45848fa5465b78b (patch) | |
tree | 6ec72b29d1feb035a9e62416865f8ad59727e138 /src/server | |
parent | 7cc79a8d62e0c98b52de04f71ef04167b8055385 (diff) | |
download | riscv-openocd-d1b882f2c014258be5397067e45848fa5465b78b.zip riscv-openocd-d1b882f2c014258be5397067e45848fa5465b78b.tar.gz riscv-openocd-d1b882f2c014258be5397067e45848fa5465b78b.tar.bz2 |
telnet_server: fix scan-build warning
fix "Declared variable-length array (VLA) has zero size" warning
raised in .../src/server/telnet_server.c:633:2:
Change-Id: Icff5228b02790c472b212a86a3849b1a3df98fdb
Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6565
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/telnet_server.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/server/telnet_server.c b/src/server/telnet_server.c index 4fc71f3..8e79626 100644 --- a/src/server/telnet_server.c +++ b/src/server/telnet_server.c @@ -615,7 +615,11 @@ static void telnet_auto_complete(struct connection *connection) while ((usr_cmd_pos < t_con->line_cursor) && isspace(t_con->line[usr_cmd_pos])) usr_cmd_pos++; - /* user command length */ + /* check user command length */ + if (t_con->line_cursor < usr_cmd_pos) { + telnet_bell(connection); + return; + } size_t usr_cmd_len = t_con->line_cursor - usr_cmd_pos; /* optimize multiple spaces in the user command, |