DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: cristian.dumitrescu@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy
Date: Mon, 31 Aug 2015 18:59:04 -0700	[thread overview]
Message-ID: <1441072746-29174-4-git-send-email-stephen@networkplumber.org> (raw)
In-Reply-To: <1441072746-29174-1-git-send-email-stephen@networkplumber.org>

Found by Coverity:
  Sizeof not portable (SIZEOF_MISMATCH)
  suspicious_sizeof: Passing argument &app->cmds[app->n_cmds] of type
  cmdline_parse_ctx_t * and argument n_cmds * 8UL /* sizeof (cmdline_parse_ctx_t *) */
  to function memcpy is suspicious.
   In this case, sizeof (cmdline_parse_ctx_t *) is equal to sizeof (cmdline_parse_ctx_t),
   but this is not a portable assumption.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 examples/ip_pipeline/init.c                                  | 2 +-
 examples/ip_pipeline/pipeline/pipeline_common_fe.c           | 2 +-
 examples/ip_pipeline/pipeline/pipeline_flow_classification.c | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c
index 3f9c68d..75e3767 100644
--- a/examples/ip_pipeline/init.c
+++ b/examples/ip_pipeline/init.c
@@ -1325,7 +1325,7 @@ app_pipeline_type_cmd_push(struct app_params *app,
 	/* Push pipeline commands into the application */
 	memcpy(&app->cmds[app->n_cmds],
 		cmds,
-		n_cmds * sizeof(cmdline_parse_ctx_t *));
+		n_cmds * sizeof(cmdline_parse_ctx_t));
 
 	for (i = 0; i < n_cmds; i++)
 		app->cmds[app->n_cmds + i]->data = app;
diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
index fcda0ce..4eec66b 100644
--- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c
+++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c
@@ -1321,7 +1321,7 @@ app_pipeline_common_cmd_push(struct app_params *app)
 	/* Push pipeline commands into the application */
 	memcpy(&app->cmds[app->n_cmds],
 		pipeline_common_cmds,
-		n_cmds * sizeof(cmdline_parse_ctx_t *));
+		n_cmds * sizeof(cmdline_parse_ctx_t));
 
 	for (i = 0; i < n_cmds; i++)
 		app->cmds[app->n_cmds + i]->data = app;
diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
index 24cf7dc..e5141b0 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c
@@ -126,7 +126,6 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key *key_in,
 	{
 		struct pkt_key_ipv6_5tuple *ipv6 = key_buffer;
 
-		memset(ipv6, 0, 64);
 		ipv6->payload_length = 0;
 		ipv6->proto = key_in->key.ipv6_5tuple.proto;
 		ipv6->hop_limit = 0;
-- 
2.1.4

  parent reply	other threads:[~2015-09-01  1:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01  1:59 [dpdk-dev] [PATCH 0/5] fixup ip pipeline examples Stephen Hemminger
2015-09-01  1:59 ` [dpdk-dev] [PATCH 1/5] examples_ip_pipeline: fix typo's Stephen Hemminger
2015-09-09 18:21   ` Dumitrescu, Cristian
2015-09-01  1:59 ` [dpdk-dev] [PATCH 2/5] example_ip_pipeline: avoid strncpy issue Stephen Hemminger
2015-09-09 18:22   ` Dumitrescu, Cristian
2015-09-10  8:44   ` Bruce Richardson
2015-09-01  1:59 ` Stephen Hemminger [this message]
2015-09-09 18:25   ` [dpdk-dev] [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy Dumitrescu, Cristian
2015-09-09 18:47     ` Stephen Hemminger
2015-09-01  1:59 ` [dpdk-dev] [PATCH 4/5] examples_ip_pipeline: remove useless code Stephen Hemminger
2015-09-09 18:31   ` Dumitrescu, Cristian
2015-09-01  1:59 ` [dpdk-dev] [PATCH 5/5] examples_ip_pipeline: fix possible string overrun Stephen Hemminger
2015-09-09 18:33   ` Dumitrescu, Cristian
2015-09-09 18:35 ` [dpdk-dev] [PATCH 0/5] fixup ip pipeline examples Dumitrescu, Cristian
2015-10-07 16:43   ` Thomas Monjalon
2015-10-12 14:51     ` Dumitrescu, Cristian

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=1441072746-29174-4-git-send-email-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /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).