From: Pablo Neira Ayuso Date: Mon, 26 Aug 2024 08:18:34 +0000 (+0200) Subject: cache: reset filter for each command X-Git-Tag: v1.1.1~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=29cb49d0ca92b840938823dec697d8c5488d7253;p=thirdparty%2Fnftables.git cache: reset filter for each command Inconditionally reset filter for each command in the batch, this is safer. Fixes: 3f1d3912c3a6 ("cache: filter out tables that are not requested") Tested-by: Eric Garver Signed-off-by: Pablo Neira Ayuso --- diff --git a/src/cache.c b/src/cache.c index 23314764..5442da35 100644 --- a/src/cache.c +++ b/src/cache.c @@ -400,6 +400,11 @@ err_name_too_long: return -1; } +static void reset_filter(struct nft_cache_filter *filter) +{ + memset(&filter->list, 0, sizeof(filter->list)); +} + int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds, struct list_head *msgs, struct nft_cache_filter *filter, unsigned int *pflags) @@ -411,8 +416,7 @@ int nft_cache_evaluate(struct nft_ctx *nft, struct list_head *cmds, if (nft_handle_validate(cmd, msgs) < 0) return -1; - if (filter->list.table && cmd->op != CMD_LIST) - memset(&filter->list, 0, sizeof(filter->list)); + reset_filter(filter); switch (cmd->op) { case CMD_ADD: