DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Ori Kam <orika@mellanox.com>, Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Bernard Iremonger <bernard.iremonger@intel.com>
Cc: dev@dpdk.org, viacheslavo@mellanox.com
Subject: Re: [dpdk-dev] [PATCH v3] app/testpmd: fix copying the name of the dynflag
Date: Fri, 31 Jan 2020 14:02:03 +0000	[thread overview]
Message-ID: <f3423074-7926-8c2e-238b-0e4d0d8d2f15@intel.com> (raw)
In-Reply-To: <1580418244-6462-1-git-send-email-orika@mellanox.com>

On 1/30/2020 9:04 PM, Ori Kam wrote:
> When working with testpmd and setting the dynflag name, we copy the
> name given by the cmd to the dynflag name.
> 
> The issue is that the size of the dynflag name is smaller then the
> string used by testpmd.
> 
> This commit solves this issue by checking that the length of the requested
> flag name is not too long.
> 
> Coverity issue: 353610
> 
> Fixes: b57b66a97ebf ("app/testpmd: support mbuf dynamic flag")
> 
> Signed-off-by: Ori Kam <orika@mellanox.com>
> ---
> V3:
>  * Fix style issue.
> 
> V2:
>  * change to check the requested flag name.
> ---
>  app/test-pmd/cmdline.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index dab22bc..7ccc778 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -18865,6 +18865,10 @@ struct cmd_config_tx_dynf_specific_result {
>  
>  	if (port_id_is_invalid(res->port_id, ENABLED_WARN))
>  		return;
> +	if (strlen(res->name) > sizeof(desc_flag.name)) {

Shouldn't it be ">=" since 'strlen' doesn't count terminating char.
It would be safer to use 'strnlen'.

> +		printf("Flag name too long\n");
> +		return;
> +	}
>  	flag = rte_mbuf_dynflag_lookup(res->name, NULL);
>  	if (flag <= 0) {
>  		strcpy(desc_flag.name, res->name);

And it would be nice to use 'strlcpy' here, to be sure target string will be
null terminated.

  reply	other threads:[~2020-01-31 14:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-30 13:22 [dpdk-dev] [PATCH] " Ori Kam
2020-01-30 16:54 ` Iremonger, Bernard
2020-01-30 18:55   ` Ori Kam
2020-01-30 19:09     ` Ori Kam
2020-01-30 20:55 ` [dpdk-dev] [PATCH v2] " Ori Kam
2020-01-30 21:04 ` [dpdk-dev] [PATCH v3] " Ori Kam
2020-01-31 14:02   ` Ferruh Yigit [this message]
2020-02-02  9:12     ` Ori Kam
2020-02-04 10:45       ` Iremonger, Bernard
2020-02-04 11:12         ` Ori Kam
2020-02-04 12:18           ` Iremonger, Bernard
2020-02-04 13:03             ` Ori Kam
2020-02-04 13:39 ` [dpdk-dev] [PATCH v4] " Ori Kam
2020-02-04 14:39   ` Iremonger, Bernard
2020-02-04 17:58     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f3423074-7926-8c2e-238b-0e4d0d8d2f15@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=orika@mellanox.com \
    --cc=viacheslavo@mellanox.com \
    --cc=wenzhuo.lu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).