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 <corubba@xxxxxx> --- Changes in v3: - Rebase onto master branch (15b89e41a536 ("all: remove trivial configure hooks")) - All other patches from v2 are already applied - Fix string-truncate compiler warning (Florian Westphal) - Link to v2: https://lore.kernel.org/netfilter-devel/1a5fff4d-4cef-48e3-a77c-bb4f7098f35b@xxxxxx/ Changes in v2: - Rebase onto master branch (b9f931e2f30e ("nfct: add icmpv6")) - Renumber the patchset since v1 patch #1 and #5 are already applied - Reduce indentation of case statements (Florian Westphal) - Link to v1: https://lore.kernel.org/netfilter-devel/ca5581f5-5e54-47f5-97c8-bcc788c77781@xxxxxx/ src/conffile.c | 12 ++++++++++++ src/ulogd.c | 2 ++ 2 files changed, 14 insertions(+) diff --git a/src/conffile.c b/src/conffile.c index e55ff30..f84fcf5 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -256,6 +256,18 @@ int config_parse_file(const char *section, struct config_keyset *kset) break; } pr_debug("parse_file: exiting main loop\n"); + + if (i == kset->num_ces) { + config_errce = calloc(1, sizeof(struct config_entry)); + if (config_errce == NULL) { + err = -ERROOM; + goto cpf_error; + } + memcpy(&config_errce->key[0], wordbuf, + sizeof(config_errce->key) - 1); + err = -ERRUNKN; + goto cpf_error; + } } 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); -- 2.48.1