From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A81302952 for ; Thu, 11 May 2017 14:53:33 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2017 05:53:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,324,1491289200"; d="scan'208";a="855552519" Received: from rhorton-mobl1.ger.corp.intel.com (HELO FC23.ir.intel.com) ([163.33.230.216]) by FMSMGA003.fm.intel.com with ESMTP; 11 May 2017 05:53:32 -0700 From: Remy Horton To: dev@dpdk.org Date: Thu, 11 May 2017 13:53:30 +0100 Message-Id: <1494507210-24538-1-git-send-email-remy.horton@intel.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH v1] metrics: fix Coverity warnings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 May 2017 12:53:34 -0000 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 --- 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