From 97ca1e786b25182199877393978decbed6608a78 Mon Sep 17 00:00:00 2001 From: Chengwen Feng Date: Wed, 5 May 2021 12:10:07 +0800 Subject: [PATCH] eal: fix service core list parsing This patch adds checking for service core index validity when parsing service corelist. Fixes: 7dbd7a6413ef ("service: add -S corelist option") Cc: stable@dpdk.org Signed-off-by: Chengwen Feng Signed-off-by: Min Hu (Connor) Acked-by: Harry van Haaren --- lib/eal/common/eal_common_options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/eal/common/eal_common_options.c b/lib/eal/common/eal_common_options.c index 66f9114715..97ab6e00fd 100644 --- a/lib/eal/common/eal_common_options.c +++ b/lib/eal/common/eal_common_options.c @@ -758,10 +758,10 @@ static int eal_parse_service_corelist(const char *corelist) { struct rte_config *cfg = rte_eal_get_configuration(); - int i, idx = 0; + int i; unsigned count = 0; char *end = NULL; - int min, max; + uint32_t min, max, idx; uint32_t taken_lcore_count = 0; if (corelist == NULL) @@ -785,6 +785,8 @@ eal_parse_service_corelist(const char *corelist) idx = strtoul(corelist, &end, 10); if (errno || end == NULL) return -1; + if (idx >= RTE_MAX_LCORE) + return -1; while (isblank(*end)) end++; if (*end == '-') { -- 2.20.1