mirror of
https://github.com/bol-van/zapret.git
synced 2024-11-29 21:40:52 +03:00
tpws: ip6_and use 64-bit and. 128 can cause alignment segfaults
This commit is contained in:
parent
33caf4fd4a
commit
6be111f7b7
@ -321,13 +321,9 @@ __attribute__((optimize ("no-strict-aliasing")))
|
|||||||
#endif
|
#endif
|
||||||
void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result)
|
void ip6_and(const struct in6_addr * restrict a, const struct in6_addr * restrict b, struct in6_addr * restrict result)
|
||||||
{
|
{
|
||||||
#ifdef __SIZEOF_INT128__
|
// int 128 can cause alignment segfaults because sin6_addr in struct sockaddr_in6 is 8-byte aligned, not 16-byte
|
||||||
// gcc and clang have 128 bit int types on some 64-bit archs. take some advantage
|
|
||||||
*((unsigned __int128*)result->s6_addr) = *((unsigned __int128*)a->s6_addr) & *((unsigned __int128*)b->s6_addr);
|
|
||||||
#else
|
|
||||||
((uint64_t*)result->s6_addr)[0] = ((uint64_t*)a->s6_addr)[0] & ((uint64_t*)b->s6_addr)[0];
|
((uint64_t*)result->s6_addr)[0] = ((uint64_t*)a->s6_addr)[0] & ((uint64_t*)b->s6_addr)[0];
|
||||||
((uint64_t*)result->s6_addr)[1] = ((uint64_t*)a->s6_addr)[1] & ((uint64_t*)b->s6_addr)[1];
|
((uint64_t*)result->s6_addr)[1] = ((uint64_t*)a->s6_addr)[1] & ((uint64_t*)b->s6_addr)[1];
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void str_cidr4(char *s, size_t s_len, const struct cidr4 *cidr)
|
void str_cidr4(char *s, size_t s_len, const struct cidr4 *cidr)
|
||||||
|
@ -13,7 +13,6 @@ typedef union
|
|||||||
{
|
{
|
||||||
struct sockaddr_in sa4; // size 16
|
struct sockaddr_in sa4; // size 16
|
||||||
struct sockaddr_in6 sa6; // size 28
|
struct sockaddr_in6 sa6; // size 28
|
||||||
char _align[32]; // force 16-byte alignment for ip6_and int128 ops
|
|
||||||
} sockaddr_in46;
|
} sockaddr_in46;
|
||||||
|
|
||||||
void rtrim(char *s);
|
void rtrim(char *s);
|
||||||
|
Loading…
Reference in New Issue
Block a user