Skip to content

Commit

Permalink
fix(userspace/libsinsp): avoid possible UB unaligned access.
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP committed Mar 19, 2024
1 parent e3e7f25 commit 58d4353
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions userspace/libsinsp/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3054,15 +3054,16 @@ void sinsp_parser::parse_bind_exit(sinsp_evt *evt)
else if (family == PPM_AF_INET6)
{
uint8_t* ip = packed_data + 1;
uint16_t port = *(uint16_t *)(packed_data + 17);
uint16_t port;
memcpy(&port, packed_data + 17, sizeof(uint16_t));
if(port > 0)
{
if(sinsp_utils::is_ipv4_mapped_ipv6(ip))
{
evt->get_fd_info()->m_type = SCAP_FD_IPV4_SERVSOCK;
evt->get_fd_info()->m_sockinfo.m_ipv4serverinfo.m_l4proto =
evt->get_fd_info()->m_sockinfo.m_ipv6info.m_fields.m_l4proto;
evt->get_fd_info()->m_sockinfo.m_ipv4serverinfo.m_ip = *(uint32_t *)(packed_data + 13);
memcpy(&evt->get_fd_info()->m_sockinfo.m_ipv4serverinfo.m_ip, packed_data + 13, sizeof(uint32_t));
evt->get_fd_info()->m_sockinfo.m_ipv4serverinfo.m_port = port;
}
else
Expand Down

0 comments on commit 58d4353

Please sign in to comment.