Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 6262
b: refs/heads/master
c: a42827b
h: refs/heads/master
v: v3
  • Loading branch information
Harald Welte authored and David S. Miller committed Aug 29, 2005
1 parent e90a40e commit 3a6b2de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 927ccbcc28dceee29dad876982768cca29738564
refs/heads/master: a42827b71b87fc9816d2f58626e825b0eb500efe
19 changes: 10 additions & 9 deletions trunk/net/netfilter/nfnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,16 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
cb_id, subsys->cb_count);
return -EINVAL;
}

attr_count = subsys->cb[cb_id].attr_count;

memset(cda, 0, sizeof(struct nfattr *) * attr_count);

/* check attribute lengths. */
min_len = NLMSG_ALIGN(sizeof(struct nfgenmsg));
if (nlh->nlmsg_len < min_len)
if (unlikely(nlh->nlmsg_len < min_len))
return -EINVAL;

if (nlh->nlmsg_len > min_len) {
attr_count = subsys->cb[cb_id].attr_count;
memset(cda, 0, sizeof(struct nfattr *) * attr_count);

/* check attribute lengths. */
if (likely(nlh->nlmsg_len > min_len)) {
struct nfattr *attr = NFM_NFA(NLMSG_DATA(nlh));
int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len);

Expand All @@ -186,8 +185,10 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys,
}
attr = NFA_NEXT(attr, attrlen);
}
} else
return -EINVAL;
}

/* implicit: if nlmsg_len == min_len, we return 0, and an empty
* (zeroed) cda[] array. The message is valid, but empty. */

return 0;
}
Expand Down

0 comments on commit 3a6b2de

Please sign in to comment.