Commit 3ebbe0cd authored by Yasuyuki Kozakai's avatar Yasuyuki Kozakai Committed by David S. Miller

[NETFILTER]: nfnetlink: Fix calculation of minimum message length

At least, valid nfnetlink message should have nlmsghdr and nfgenmsg.
Signed-off-by: default avatarYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f16c9107
...@@ -162,7 +162,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys, ...@@ -162,7 +162,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
return -EINVAL; return -EINVAL;
} }
min_len = NLMSG_ALIGN(sizeof(struct nfgenmsg)); min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
if (unlikely(nlh->nlmsg_len < min_len)) if (unlikely(nlh->nlmsg_len < min_len))
return -EINVAL; return -EINVAL;
...@@ -236,8 +236,7 @@ static inline int nfnetlink_rcv_msg(struct sk_buff *skb, ...@@ -236,8 +236,7 @@ static inline int nfnetlink_rcv_msg(struct sk_buff *skb,
} }
/* All the messages must at least contain nfgenmsg */ /* All the messages must at least contain nfgenmsg */
if (nlh->nlmsg_len < if (nlh->nlmsg_len < NLMSG_SPACE(sizeof(struct nfgenmsg))) {
NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg)))) {
DEBUGP("received message was too short\n"); DEBUGP("received message was too short\n");
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment