From: Phil Sutter <phil@nwl.cc>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Subject: [nft PATCH] monitor: Fix for incorrect debug_mask
Date: Thu, 21 Sep 2017 20:38:02 +0200 [thread overview]
Message-ID: <20170921183802.27797-1-phil@nwl.cc> (raw)
The field 'debug_mask' of struct netlink_mon_handler was left
uninitialized in do_command_monitor() so it contained garbage from the
stack. Fix this by initializing it with the debug_mask value from struct
netlink_ctx.
While being at it, change the code to make use of C99-style initializer,
which will also avoid things like this in future.
Fixes: be441e1ffdc24 ("src: add debugging mask to context structure")
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
src/rule.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/rule.c b/src/rule.c
index 1bb7b4756171c..8f0e752f21fba 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1690,7 +1690,14 @@ static int do_command_monitor(struct netlink_ctx *ctx, struct cmd *cmd)
{
struct table *t;
struct set *s;
- struct netlink_mon_handler monhandler;
+ struct netlink_mon_handler monhandler = {
+ .monitor_flags = cmd->monitor->flags,
+ .format = cmd->monitor->format,
+ .ctx = ctx,
+ .loc = &cmd->location,
+ .cache = ctx->cache,
+ .debug_mask = ctx->debug_mask,
+ };
monhandler.cache_needed = need_cache(cmd);
if (monhandler.cache_needed) {
@@ -1725,12 +1732,6 @@ static int do_command_monitor(struct netlink_ctx *ctx, struct cmd *cmd)
}
}
- monhandler.monitor_flags = cmd->monitor->flags;
- monhandler.format = cmd->monitor->format;
- monhandler.ctx = ctx;
- monhandler.loc = &cmd->location;
- monhandler.cache = ctx->cache;
-
return netlink_monitor(&monhandler, ctx->nf_sock);
}
--
2.13.1
next reply other threads:[~2017-09-21 18:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 18:38 Phil Sutter [this message]
2017-09-27 12:11 ` [nft PATCH] monitor: Fix for incorrect debug_mask Pablo Neira Ayuso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170921183802.27797-1-phil@nwl.cc \
--to=phil@nwl.cc \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).