Skip to content

Commit

Permalink
app/testpmd: avoid potential outside of array reference
Browse files Browse the repository at this point in the history
The order of comparison is wrong, and potentially allows
referencing past the array.

Link: https://pvs-studio.com/en/blog/posts/cpp/1179/
Fixes: 3e3edab ("ethdev: add flow quota")
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
  • Loading branch information
shemminger authored and tmonjalo committed Nov 26, 2024
1 parent 4c2e746 commit f86085c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/test-pmd/cmdline_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -12892,7 +12892,7 @@ comp_names_to_index(struct context *ctx, const struct token *token,
RTE_SET_USED(token);
if (!buf)
return names_size;
if (names[ent] && ent < names_size)
if (ent < names_size && names[ent] != NULL)
return rte_strscpy(buf, names[ent], size);
return -1;

Expand Down

0 comments on commit f86085c

Please sign in to comment.