From: Corubba Smith Date: Sat, 8 Mar 2025 22:36:33 +0000 (+0100) Subject: ulogd: ignore malformed config directives X-Git-Tag: ulogd-2.0.9~14 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=752117f7eacd5558145c0921caacea2e8b57417d;p=thirdparty%2Fulogd2.git ulogd: ignore malformed config directives When a config directive is provided with a malformed argument (e.g. `loglevel="1`), then the call to get_word() returns NULL and `wordbuf` is left unchanged aka still contains the directive name. Unlike the previous calls to get_word(), the return value is not checked here, and processing continues with `args` pointing to the still unchanged `wordbuf`. So `loglevel="1` is effectively parsed as `loglevel=loglevel`. Instead if no valid argument is found, ignore the directive and log a warning. Due to the way get_word() is implemented, this unfortunately will report an empty argument (e.g. `loglevel=`) as malformed as well. Ideally that should behave the same as `loglevel=""`, but I found no nice way to achieve that. An empty argument is only useful in rare cases, so treating it as malformed should be fine for now. That's still way better than the previous broken "name as value" behaviour. Fixes: e88384d9d5a1 ("added new generic get_word() function to do better parsing") Signed-off-by: Corubba Smith Signed-off-by: Florian Westphal --- diff --git a/src/conffile.c b/src/conffile.c index 5b7f834..cc5552c 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -198,6 +198,12 @@ int config_parse_file(const char *section, struct config_keyset *kset) } wordend = get_word(wordend, " =\t\n\r", (char *) &wordbuf); + if (wordend == NULL) { + ulogd_log(ULOGD_NOTICE, + "ignoring malformed config directive \"%s\" on line %d\n", + ce->key, linenum); + break; + } args = (char *)&wordbuf; if (ce->hit && !(ce->options & CONFIG_OPT_MULTI))