DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: declan.doherty@intel.com
Cc: dev@dpdk.org, Pablo de Lara <pablo.de.lara.guarch@intel.com>
Subject: [dpdk-dev] [PATCH] examples/l2fwd-crypto: fix overflow
Date: Tue,  7 Feb 2017 14:17:25 +0000	[thread overview]
Message-ID: <1486477045-86810-1-git-send-email-pablo.de.lara.guarch@intel.com> (raw)

This commit fixes an array overflow when number of crypto devices
is higher than 32.

Fixes: 387259bd6c67 ("examples/l2fwd-crypto: add sample application")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 examples/l2fwd-crypto/main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 43fef59..bc88be5 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -200,7 +200,7 @@ struct lcore_queue_conf {
 	unsigned nb_crypto_devs;
 	unsigned cryptodev_list[MAX_RX_QUEUE_PER_LCORE];
 
-	struct op_buffer op_buf[RTE_MAX_ETHPORTS];
+	struct op_buffer op_buf[RTE_CRYPTO_MAX_DEVS];
 	struct pkt_buffer pkt_buf[RTE_MAX_ETHPORTS];
 } __rte_cache_aligned;
 
@@ -299,7 +299,7 @@ print_stats(void)
 
 	for (cdevid = 0; cdevid < RTE_CRYPTO_MAX_DEVS; cdevid++) {
 		/* skip disabled ports */
-		if ((l2fwd_enabled_crypto_mask & (1lu << cdevid)) == 0)
+		if ((l2fwd_enabled_crypto_mask & (((uint64_t)1) << cdevid)) == 0)
 			continue;
 		printf("\nStatistics for cryptodev %"PRIu64
 				" -------------------------"
@@ -1808,7 +1808,7 @@ initialize_cryptodevs(struct l2fwd_crypto_options *options, unsigned nb_ports,
 			return -1;
 		}
 
-		l2fwd_enabled_crypto_mask |= (1 << cdev_id);
+		l2fwd_enabled_crypto_mask |= (((uint64_t)1) << cdev_id);
 
 		enabled_cdevs[cdev_id] = 1;
 		enabled_cdev_count++;
-- 
2.7.4

             reply	other threads:[~2017-02-07 14:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07 14:17 Pablo de Lara [this message]
2017-02-09 18:24 ` Zhang, Roy Fan
2017-02-10  0:37   ` De Lara Guarch, Pablo

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=1486477045-86810-1-git-send-email-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@intel.com \
    --cc=declan.doherty@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).