From f3687f251e14689900e24b39bf187bf251208407 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 27 Apr 2020 16:16:25 -0700 Subject: [PATCH] cfgfile: check flags on creation for future proofing All API's should check that they support the flag values passed. If an application passes an invalid flag it could cause problems in later ABI. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson Acked-by: Konstantin Ananyev --- lib/librte_cfgfile/rte_cfgfile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index 9049fd9c23..714717dd90 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -272,6 +272,10 @@ rte_cfgfile_create(int flags) int i; struct rte_cfgfile *cfg; + /* future proof flags usage */ + if (flags & ~(CFG_FLAG_GLOBAL_SECTION | CFG_FLAG_EMPTY_VALUES)) + return NULL; + cfg = malloc(sizeof(*cfg)); if (cfg == NULL) -- 2.20.1