From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id EF9405587 for ; Tue, 18 Apr 2017 16:22:23 +0200 (CEST) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id CD61B2A349; Tue, 18 Apr 2017 16:22:14 +0200 (CEST) From: Olivier Matz To: dev@dpdk.org Cc: ferruh.yigit@intel.com, jianfeng.tan@intel.com, thomas@monjalon.net Date: Tue, 18 Apr 2017 16:22:24 +0200 Message-Id: <20170418142225.6308-5-olivier.matz@6wind.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170418142225.6308-1-olivier.matz@6wind.com> References: <20170418142225.6308-1-olivier.matz@6wind.com> Subject: [dpdk-dev] [PATCH 5/6] eal: fix log level regexp matching 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: Tue, 18 Apr 2017 14:22:24 -0000 Fix misuse of regular expression functions, which was producing a segfault. After the patch, it works properly: $ ./build/app/test --no-huge --log-level=pmd,3 RTE>>dump_log_types [...] id 30: user7, level is debug id 31: user8, level is debug id 32: pmd.i40e.init, level is critical id 33: pmd.i40e.driver, level is critical Fixes: a5279180f510 ("eal: change several log levels matching a regexp") Coverity issue: 143472 Reported-by: Jianfeng Tan Signed-off-by: Olivier Matz --- lib/librte_eal/common/eal_common_log.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 7d13cc026..c2957d167 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -159,10 +159,14 @@ rte_log_set_level_regexp(const char *pattern, uint32_t level) if (level > RTE_LOG_DEBUG) return -1; + if (regcomp(&r, pattern, 0) != 0) + return -1; + for (i = 0; i < rte_logs.dynamic_types_len; i++) { if (rte_logs.dynamic_types[i].name == NULL) continue; - if (regexec(&r, pattern, 0, NULL, 0) == 0) + if (regexec(&r, rte_logs.dynamic_types[i].name, 0, + NULL, 0) == 0) rte_logs.dynamic_types[i].loglevel = level; } -- 2.11.0