Skip to content

Commit

Permalink
cleanup(libsinsp): remove some more misaligned accesses
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra authored and poiana committed Feb 22, 2024
1 parent d8bfc3c commit 2eaf8a1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions userspace/libsinsp/fdinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ class SINSP_PUBLIC sinsp_fdinfo

inline void set_unix_info(uint8_t* packed_data)
{
m_sockinfo.m_unixinfo.m_fields.m_source = *(uint64_t *)(packed_data + 1);
m_sockinfo.m_unixinfo.m_fields.m_dest = *(uint64_t *)(packed_data + 9);
memcpy(&m_sockinfo.m_unixinfo.m_fields.m_source, packed_data + 1, sizeof(uint64_t));
memcpy(&m_sockinfo.m_unixinfo.m_fields.m_dest, packed_data + 9, sizeof(uint64_t));
}

/*!
Expand Down
14 changes: 4 additions & 10 deletions userspace/libsinsp/sinsp_filtercheck_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,9 +634,7 @@ uint8_t* sinsp_filter_check_event::extract_error_count(sinsp_evt *evt, OUT uint3

if(pi != NULL)
{
ASSERT(pi->m_len == sizeof(uint64_t));

int64_t res = *(int64_t*)pi->m_val;
int64_t res = pi->as<int64_t>();
if(res < 0)
{
m_u32val = 1;
Expand All @@ -654,9 +652,7 @@ uint8_t* sinsp_filter_check_event::extract_error_count(sinsp_evt *evt, OUT uint3

if(pi != NULL)
{
ASSERT(pi->m_len == sizeof(uint64_t));

int64_t res = *(int64_t*)pi->m_val;
int64_t res = pi->as<int64_t>();
if(res < 0)
{
m_u32val = 1;
Expand Down Expand Up @@ -1202,9 +1198,7 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo

if(pi != NULL)
{
ASSERT(pi->m_len == sizeof(int64_t));

int64_t res = *(int64_t*)pi->m_val;
int64_t res = pi->as<int64_t>();

if(res >= 0)
{
Expand Down Expand Up @@ -1232,7 +1226,7 @@ uint8_t* sinsp_filter_check_event::extract(sinsp_evt *evt, OUT uint32_t* len, bo
pi = evt->get_param_by_name("fd");
if (pi)
{
int64_t res = *(int64_t*)pi->m_val;
int64_t res = pi->as<int64_t>();

if(res >= 0)
{
Expand Down

0 comments on commit 2eaf8a1

Please sign in to comment.