DPDK patches and discussions
 help / color / mirror / Atom feed
From: Remy Horton <remy.horton@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v1] metrics: fix Coverity warnings
Date: Thu, 11 May 2017 13:53:30 +0100	[thread overview]
Message-ID: <1494507210-24538-1-git-send-email-remy.horton@intel.com> (raw)

Fixes memory access errors detected by Coverity.
All cases are the maximum permissable value causing an
out-by-one overrun.

Coverity issue 143433: Memory - illigal access
Coverity issue 143434: Memory - illigal access
Coverity issue 143460: Memory - corruptins
Coverity issue 143464: Memory - illigal access

Fixes: 349950ddb9c5 ("metrics: add information metrics library")

Signed-off-by: Remy Horton <remy.horton@intel.com>
---
 lib/librte_metrics/rte_metrics.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c
index e9a122c..6e61f9b 100644
--- a/lib/librte_metrics/rte_metrics.c
+++ b/lib/librte_metrics/rte_metrics.c
@@ -51,7 +51,7 @@
  */
 struct rte_metrics_meta_s {
 	/** Name of metric */
-	char name[RTE_METRICS_MAX_NAME_LEN];
+	char name[RTE_METRICS_MAX_NAME_LEN + 1];
 	/** Current value for metric */
 	uint64_t value[RTE_MAX_ETHPORTS];
 	/** Used for global metrics */
@@ -176,7 +176,7 @@ rte_metrics_update_values(int port_id,
 	uint16_t cnt_setsize;
 
 	if (port_id != RTE_METRICS_GLOBAL &&
-			(port_id < 0 || port_id > RTE_MAX_ETHPORTS))
+			(port_id < 0 || port_id >= RTE_MAX_ETHPORTS))
 		return -EINVAL;
 
 	if (values == NULL)
@@ -263,7 +263,7 @@ rte_metrics_get_values(int port_id,
 	int return_value;
 
 	if (port_id != RTE_METRICS_GLOBAL &&
-			(port_id < 0 || port_id > RTE_MAX_ETHPORTS))
+			(port_id < 0 || port_id >= RTE_MAX_ETHPORTS))
 		return -EINVAL;
 
 	memzone = rte_memzone_lookup(RTE_METRICS_MEMZONE_NAME);
-- 
2.5.5

             reply	other threads:[~2017-05-11 12:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-11 12:53 Remy Horton [this message]
2017-06-05 13:32 ` Thomas Monjalon

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=1494507210-24538-1-git-send-email-remy.horton@intel.com \
    --to=remy.horton@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).