Skip sizechecking if it's zero
Pablo Neira
maintainerPATCH 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).
Signed-off-by Pablo Neira Ayuso <[email protected]>
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.
Signed-off-by Pablo Neira Ayuso <[email protected]>
include/linux/netfilter/nfnetlink.h +4 -1
@@ -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; \ })