Make pfctl(8) work on strict-alignment platforms, by copying a pair of
embedded structures out of a packed, unaligned struct into local copies on the stack which are aligned. The original patch to do this was submitted by Guy Yur <guyyur@gmail.com>, and this is conceptually the same change, but restructured with the #ifndef __NO_STRICT_ALIGNMENT wrapper, similar to how the same issue is handled in the kernel pf code. PR: 185617 PR: 206658
This commit is contained in:
parent
bd9b38d1f7
commit
1cac26262e
@ -208,22 +208,30 @@ void
|
||||
print_state(struct pfsync_state *s, int opts)
|
||||
{
|
||||
struct pfsync_state_peer *src, *dst;
|
||||
struct pfsync_state_key *sk, *nk;
|
||||
struct pfsync_state_key *key, *sk, *nk;
|
||||
struct protoent *p;
|
||||
int min, sec;
|
||||
#ifndef __NO_STRICT_ALIGNMENT
|
||||
struct pfsync_state_key aligned_key[2];
|
||||
|
||||
bcopy(&s->key, aligned_key, sizeof(aligned_key));
|
||||
key = aligned_key;
|
||||
#else
|
||||
key = s->key;
|
||||
#endif
|
||||
|
||||
if (s->direction == PF_OUT) {
|
||||
src = &s->src;
|
||||
dst = &s->dst;
|
||||
sk = &s->key[PF_SK_STACK];
|
||||
nk = &s->key[PF_SK_WIRE];
|
||||
sk = &key[PF_SK_STACK];
|
||||
nk = &key[PF_SK_WIRE];
|
||||
if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6)
|
||||
sk->port[0] = nk->port[0];
|
||||
} else {
|
||||
src = &s->dst;
|
||||
dst = &s->src;
|
||||
sk = &s->key[PF_SK_WIRE];
|
||||
nk = &s->key[PF_SK_STACK];
|
||||
sk = &key[PF_SK_WIRE];
|
||||
nk = &key[PF_SK_STACK];
|
||||
if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6)
|
||||
sk->port[1] = nk->port[1];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user