diff mbox series

[v2,06/11] eal: catch invalid log level number

Message ID 20210310132825.2627851-7-thomas@monjalon.net (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers show
Series improve options help | expand

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Thomas Monjalon March 10, 2021, 1:28 p.m. UTC
The parsing check for invalid log level was not trying to catch
irrelevant numeric values.
A log level 0 or too high is now a failure in options parsing
so it can be caught early.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/common/eal_common_options.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c
index 3675e55fc9..da0aaf831e 100644
--- a/lib/librte_eal/common/eal_common_options.c
+++ b/lib/librte_eal/common/eal_common_options.c
@@ -1289,7 +1289,7 @@  eal_parse_log_level(const char *arg)
 	}
 
 	priority = eal_parse_log_priority(level);
-	if (priority < 0) {
+	if (priority <= 0 || priority > (int) RTE_LOG_MAX) {
 		fprintf(stderr, "invalid log priority: %s\n", level);
 		goto fail;
 	}