From 1b4e27768b375e646528a1b622391a95f8c25b25 Mon Sep 17 00:00:00 2001 From: Corubba Smith Date: Wed, 12 Mar 2025 20:09:36 +0100 Subject: ulogd: raise error on unknown config key Until a6fbeb96e889 ("new configuration file syntax (Magnus Boden)") this was already caught, and the enum member is still present. Check if the for loop worked throught the whole array without hitting a matching config option, and return with the unknown key error code. Because there is no existing config_entry struct with that unknwon key to use with the established config_errce pointer, allocate a new struct. This potentially creates a memory leak if that config_entry is never freed again, but for me that is acceptable in this rare case. Since the memory allocation for the struct can fail, also reuse the old out-of-memory error to indicate that. Signed-off-by: Corubba Smith Signed-off-by: Florian Westphal --- src/ulogd.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ulogd.c') diff --git a/src/ulogd.c b/src/ulogd.c index b146f94..917ae3a 100644 --- a/src/ulogd.c +++ b/src/ulogd.c @@ -281,6 +281,8 @@ int ulogd_parse_configfile(const char *section, struct config_keyset *ce) case -ERRUNKN: ulogd_log(ULOGD_ERROR, "unknown config key \"%s\"\n", config_errce->key); + free(config_errce); + config_errce = NULL; break; case -ERRSECTION: ulogd_log(ULOGD_ERROR, "section \"%s\" not found\n", section); -- cgit v1.2.3