From: Remy Horton Date: Thu, 11 May 2017 12:53:30 +0000 (+0100) Subject: metrics: fix out of bound access X-Git-Tag: spdx-start~3193 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=710cab6f675a2dbad2cdad6942aa379db5d7a508;p=dpdk.git metrics: fix out of bound access Fixes memory access errors detected by Coverity. All cases are the maximum permissable value causing an out-by-one overrun. Coverity issue: 143433, 143434, 143460, 143464 Fixes: 349950ddb9c5 ("metrics: add information metrics library") Signed-off-by: Remy Horton --- diff --git a/lib/librte_metrics/rte_metrics.c b/lib/librte_metrics/rte_metrics.c index e9a122c1fb..6e61f9b1ba 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);