examples/pipeline: fix CLI parsing crash
authorCristian Dumitrescu <cristian.dumitrescu@intel.com>
Thu, 28 Jan 2021 19:12:39 +0000 (19:12 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Fri, 29 Jan 2021 15:20:58 +0000 (16:20 +0100)
Cannot dereference pointer for token[1] unless valid.

Fixes: 5074e1d551 ("examples/pipeline: add configuration commands")
Cc: stable@dpdk.org
Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
examples/pipeline/cli.c

index d0150cf..e97e120 100644 (file)
@@ -1294,7 +1294,7 @@ cli_process(char *in, char *out, size_t out_size, void *obj)
        }
 
        if (strcmp(tokens[0], "link") == 0) {
-               if (strcmp(tokens[1], "show") == 0) {
+               if ((n_tokens >= 2) && (strcmp(tokens[1], "show") == 0)) {
                        cmd_link_show(tokens, n_tokens, out, out_size, obj);
                        return;
                }