ip/xfrm: Fix deleteall when having many policies installed

Fix "Policy buffer overflow" when trying to use deleteall with many
policies installed.

Signed-off-by: Alexander Heinlein <alexander.heinlein@secunet.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
This commit is contained in:
Alexander Heinlein 2017-01-16 14:48:25 +01:00 committed by Stephen Hemminger
parent c3d09fba93
commit d5eb0564da
1 changed files with 2 additions and 4 deletions

View File

@ -732,10 +732,8 @@ static int xfrm_policy_keep(const struct sockaddr_nl *who,
if (!xfrm_policy_filter_match(xpinfo, ptype))
return 0;
if (xb->offset > xb->size) {
fprintf(stderr, "Policy buffer overflow\n");
return -1;
}
if (xb->offset + NLMSG_LENGTH(sizeof(*xpid)) > xb->size)
return 0;
new_n = (struct nlmsghdr *)(xb->buf + xb->offset);
new_n->nlmsg_len = NLMSG_LENGTH(sizeof(*xpid));