aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/netlink/netlink_message_parser.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/netlink/netlink_message_parser.h b/sys/netlink/netlink_message_parser.h
index 8f61091c4a7f..c747f301059c 100644
--- a/sys/netlink/netlink_message_parser.h
+++ b/sys/netlink/netlink_message_parser.h
@@ -315,6 +315,12 @@ static inline void
nl_get_attrs_bmask_nlmsg(struct nlmsghdr *hdr,
const struct nlhdr_parser *parser, struct nlattr_bmask *bm)
{
+ if (__predict_false(hdr->nlmsg_len - sizeof(struct nlmsghdr) <
+ parser->nl_hdr_off)) {
+ /* Doesn't make sense to call nl_alloc_compat_hdr() here. */
+ BIT_ZERO(NL_ATTR_BMASK_SIZE, bm);
+ return;
+ }
nl_get_attrs_bmask_raw(
(struct nlattr *)((char *)(hdr + 1) + parser->nl_hdr_off),
hdr->nlmsg_len - sizeof(*hdr) - parser->nl_hdr_off, bm);