diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2013-07-19 21:54:02 +0200 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2013-07-19 21:54:02 +0200 |
commit | 6d08c3b300e97e1b334f84a2eef4c9af190a51d9 (patch) | |
tree | f5c44f560f0b05194fc822b813446cbe6d523e31 /lib/debug.c | |
parent | 81b95c05e77cba00cf98a027b01f6261d998dcfa (diff) | |
download | ipset-6d08c3b300e97e1b334f84a2eef4c9af190a51d9.tar.gz |
Report broken netlink messages in debug mode
Diffstat (limited to 'lib/debug.c')
-rw-r--r-- | lib/debug.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/debug.c b/lib/debug.c index 1350053..3aa5a99 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -236,6 +236,19 @@ ipset_debug_msg(const char *dir, void *buffer, int len) int cmd, nfmsglen = MNL_ALIGN(sizeof(struct nfgenmsg)); debug = 0; + if (!mnl_nlmsg_ok(nlh, len)) { + fprintf(stderr, "Broken message received!\n"); + if (len < (int)sizeof(struct nlmsghdr)) { + fprintf(stderr, "len (%d) < sizeof(struct nlmsghdr) (%d)\n", + len, (int)sizeof(struct nlmsghdr)); + } else if (nlh->nlmsg_len < sizeof(struct nlmsghdr)) { + fprintf(stderr, "nlmsg_len (%u) < sizeof(struct nlmsghdr) (%d)\n", + nlh->nlmsg_len, (int)sizeof(struct nlmsghdr)); + } else if ((int)nlh->nlmsg_len > len) { + fprintf(stderr, "nlmsg_len (%u) > len (%d)\n", + nlh->nlmsg_len, len); + } + } while (mnl_nlmsg_ok(nlh, len)) { switch (nlh->nlmsg_type) { case NLMSG_NOOP: |