summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.c13
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: