[PATCH v4 9/9] app/test-pmd: avoid potential outside of array reference

fengchengwen fengchengwen at huawei.com
Fri Nov 22 01:33:20 CET 2024


Acked-by: Chengwen Feng <fengchengwen at huawei.com>

On 2024/11/22 2:23, Stephen Hemminger wrote:
> The order of comparison is wrong, and potentially allows
> referencing past the array.
> 
> Link: https://pvs-studio.com/en/blog/posts/cpp/1179/
> 
> Fixes: 3e3edab530a1 ("ethdev: add flow quota")
> Cc: getelson at nvidia.com
> Cc: stable at dpdk.org
> 
> Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
> Acked-by: Bruce Richardson <bruce.richardson at intel.com>
> ---
>  app/test-pmd/cmdline_flow.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
> index 1e4f2ebc55..9e4fc2d95d 100644
> --- a/app/test-pmd/cmdline_flow.c
> +++ b/app/test-pmd/cmdline_flow.c
> @@ -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;
>  



More information about the stable mailing list