[NETFILTER]: nfnetlink: Fix calculation of minimum message length
authorYasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Mon, 5 Dec 2005 21:33:26 +0000 (13:33 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Dec 2005 21:33:26 +0000 (13:33 -0800)
At least, valid nfnetlink message should have nlmsghdr and nfgenmsg.

Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netfilter/nfnetlink.c

index a60c59b97631abbb51dda4268dc50fa000445fb4..95fdf04f1d88d239b37bdc26e8aeaeee79b0187f 100644 (file)
@@ -162,7 +162,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
                return -EINVAL;
        }
 
-       min_len = NLMSG_ALIGN(sizeof(struct nfgenmsg));
+       min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
        if (unlikely(nlh->nlmsg_len < min_len))
                return -EINVAL;
 
@@ -236,8 +236,7 @@ static inline int nfnetlink_rcv_msg(struct sk_buff *skb,
        }
 
        /* All the messages must at least contain nfgenmsg */
-       if (nlh->nlmsg_len < 
-                       NLMSG_LENGTH(NLMSG_ALIGN(sizeof(struct nfgenmsg)))) {
+       if (nlh->nlmsg_len < NLMSG_SPACE(sizeof(struct nfgenmsg))) {
                DEBUGP("received message was too short\n");
                return 0;
        }