mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Avoid passing address of member in packed struct #1074
This appeases -Waddress-of-packed-member warnings in some compiler/platform combinations via use of local variables.
This commit is contained in:
parent
4f53e48750
commit
bdd624d8b8
1 changed files with 12 additions and 4 deletions
|
@ -230,21 +230,29 @@ void PIA_TCP::FirstPacket(bool is_orig, const IP_Hdr* ip)
|
||||||
ip4_hdr = new IP_Hdr(ip4, false);
|
ip4_hdr = new IP_Hdr(ip4, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Locals used to avoid potentil alignment problems
|
||||||
|
// with some archs/compilers when grabbing the address
|
||||||
|
// of the struct member directly in the following.
|
||||||
|
in_addr tmp_src;
|
||||||
|
in_addr tmp_dst;
|
||||||
|
|
||||||
if ( is_orig )
|
if ( is_orig )
|
||||||
{
|
{
|
||||||
Conn()->OrigAddr().CopyIPv4(&ip4->ip_src);
|
Conn()->OrigAddr().CopyIPv4(&tmp_src);
|
||||||
Conn()->RespAddr().CopyIPv4(&ip4->ip_dst);
|
Conn()->RespAddr().CopyIPv4(&tmp_dst);
|
||||||
tcp4->th_sport = htons(Conn()->OrigPort());
|
tcp4->th_sport = htons(Conn()->OrigPort());
|
||||||
tcp4->th_dport = htons(Conn()->RespPort());
|
tcp4->th_dport = htons(Conn()->RespPort());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Conn()->RespAddr().CopyIPv4(&ip4->ip_src);
|
Conn()->RespAddr().CopyIPv4(&tmp_src);
|
||||||
Conn()->OrigAddr().CopyIPv4(&ip4->ip_dst);
|
Conn()->OrigAddr().CopyIPv4(&tmp_dst);
|
||||||
tcp4->th_sport = htons(Conn()->RespPort());
|
tcp4->th_sport = htons(Conn()->RespPort());
|
||||||
tcp4->th_dport = htons(Conn()->OrigPort());
|
tcp4->th_dport = htons(Conn()->OrigPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ip4->ip_src = tmp_src;
|
||||||
|
ip4->ip_dst = tmp_dst;
|
||||||
ip = ip4_hdr;
|
ip = ip4_hdr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue