]> git.ipfire.org Git - thirdparty/ulogd2.git/commit
ulogd: ignore malformed config directives
authorCorubba Smith <corubba@gmx.de>
Sat, 8 Mar 2025 22:36:33 +0000 (23:36 +0100)
committerFlorian Westphal <fw@strlen.de>
Wed, 12 Mar 2025 08:10:06 +0000 (09:10 +0100)
commit752117f7eacd5558145c0921caacea2e8b57417d
tree944c3843a46ad55909b64428eec9d9a0fa10a5f8
parent4c2a07b55d9e8a8366a1d3f5d04a2e6b971c0475
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 <corubba@gmx.de>
Signed-off-by: Florian Westphal <fw@strlen.de>
src/conffile.c