Skip to contentSkip to conversation

Remove duplicate checkings in nfnetlink_check_attributes

PATCH In review Pablo Neira Ayuso 1 participant 1 message Feb 15, 2007

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 3/6 Remove duplicate checkings in nfnetlink_check_attributes

nfnetlink_check_attributes duplicates message size and callback id checkings. nfnetlink_find_client and nfnetlink_rcv_msg already do such checkings.

Signature · 2 lines
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris

[PATCH] Remove duplicate checkings in nfnetlink_check_attributes

nfnetlink_check_attributes duplicates message size and callback id checkings. nfnetlink_find_client and nfnetlink_rcv_msg already do such checkings.

net/netfilter/nfnetlink.c +1 -8
Index: net-2.6.git/net/netfilter/nfnetlink.c
===================================================================
@@ -127,17 +127,10 @@ static int
 nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
 			   struct nlmsghdr *nlh, struct nfattr *cda[])
 {
-	int min_len;
+	int min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
 	u_int16_t attr_count;
 	u_int8_t cb_id = NFNL_MSG_TYPE(nlh->nlmsg_type);
 
-	if (unlikely(cb_id >= subsys->cb_count))
-		return -EINVAL;
-
-	min_len = NLMSG_SPACE(sizeof(struct nfgenmsg));
-	if (unlikely(nlh->nlmsg_len < min_len))
-		return -EINVAL;
-
 	attr_count = subsys->cb[cb_id].attr_count;
 	memset(cda, 0, sizeof(struct nfattr *) * attr_count);