提交 906b1c39 编写于 作者: M Matthias Schiffer 提交者: Pablo Neira Ayuso

netfilter: ip6t_NPT: Fix translation for non-multiple of 32 prefix lengths

The bitmask used for the prefix mangling was being calculated
incorrectly, leading to the wrong part of the address being replaced
when the prefix length wasn't a multiple of 32.
Signed-off-by: NMatthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: NPablo Neira Ayuso <pablo@netfilter.org>
上级 5389090b
...@@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt, ...@@ -57,7 +57,7 @@ static bool ip6t_npt_map_pfx(const struct ip6t_npt_tginfo *npt,
if (pfx_len - i >= 32) if (pfx_len - i >= 32)
mask = 0; mask = 0;
else else
mask = htonl(~((1 << (pfx_len - i)) - 1)); mask = htonl((1 << (i - pfx_len + 32)) - 1);
idx = i / 32; idx = i / 32;
addr->s6_addr32[idx] &= mask; addr->s6_addr32[idx] &= mask;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册