mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-04-11 03:31:36 +00:00
CLEANUP: sample: use read_u64() in ipmask() to apply an IPv6 mask
There were 8 strict aliasing warnings there due to the dereferences casting to uint32_t of input and output. We can achieve the same using two write_u64() and four read_u64() which do not cause this issue and even let the compiler use 64-bit operations.
This commit is contained in:
parent
6cde5d883c
commit
a8b7ecd4dc
@ -22,6 +22,7 @@
|
||||
#include <common/hash.h>
|
||||
#include <common/http.h>
|
||||
#include <common/initcall.h>
|
||||
#include <common/net_helper.h>
|
||||
#include <common/standard.h>
|
||||
#include <common/uri_auth.h>
|
||||
#include <common/base64.h>
|
||||
@ -1750,10 +1751,10 @@ static int sample_conv_ipmask(const struct arg *args, struct sample *smp, void *
|
||||
if (args[1].type != ARGT_IPV6)
|
||||
return 0;
|
||||
|
||||
*(uint32_t*)&smp->data.u.ipv6.s6_addr[0] &= *(uint32_t*)&args[1].data.ipv6.s6_addr[0];
|
||||
*(uint32_t*)&smp->data.u.ipv6.s6_addr[4] &= *(uint32_t*)&args[1].data.ipv6.s6_addr[4];
|
||||
*(uint32_t*)&smp->data.u.ipv6.s6_addr[8] &= *(uint32_t*)&args[1].data.ipv6.s6_addr[8];
|
||||
*(uint32_t*)&smp->data.u.ipv6.s6_addr[12] &= *(uint32_t*)&args[1].data.ipv6.s6_addr[12];
|
||||
write_u64(&smp->data.u.ipv6.s6_addr[0],
|
||||
read_u64(&smp->data.u.ipv6.s6_addr[0]) & read_u64(&args[1].data.ipv6.s6_addr[0]));
|
||||
write_u64(&smp->data.u.ipv6.s6_addr[8],
|
||||
read_u64(&smp->data.u.ipv6.s6_addr[8]) & read_u64(&args[1].data.ipv6.s6_addr[8]));
|
||||
smp->data.type = SMP_T_IPV6;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user