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: 349950ddb9
("metrics: add information metrics library")
Signed-off-by: Remy Horton <remy.horton@intel.com>
This commit is contained in:
parent
bbdb713665
commit
710cab6f67
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user