Skip to contentSkip to conversation

Skip sizechecking if it's zero

PATCH Applied Pablo Neira 1 participant 1 message Nov 8, 2005 netfilter

lore
Share & tools
lore

Pablo Neira

author maintainer
#0 lore raw

PATCH 7/8 Skip sizechecking if it's zero

Skip sizecheck if the size of the attribute wasn't specified, ie. zero. The idea is providing a way to sizecheck leaf attributes and ignore the nest (that has variable size depending on the leaves). This way we can sizecheck at the beginning of every operation instead of polluting the code with sizecheckings everywhere. Please, have a look at the next patch (8/8).

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

Skip sizecheck if the size of the attribute wasn't specified, ie. zero.

include/linux/netfilter/nfnetlink.h +4 -1
Index: netfilter-2.6.14.git/include/linux/netfilter/nfnetlink.h
===================================================================
@@ -154,11 +154,14 @@ extern void nfattr_parse(struct nfattr *
 
 #define nfattr_bad_size(tb, max, cta_min)				\
 ({	int __i, __res = 0;						\
- 	for (__i=0; __i<max; __i++) 					\
+ 	for (__i=0; __i<max; __i++) {					\
+ 		if (!cta_min[__i])					\
+ 			continue;					\
  		if (tb[__i] && NFA_PAYLOAD(tb[__i]) < cta_min[__i]){	\
  			__res = 1;					\
  			break;						\
  		}							\
+ 	}								\
  	__res;								\
 })