From ff0ea6d759fcd03bebf6dfd855970f730c0c3e48 Mon Sep 17 00:00:00 2001 From: Luca Guerra Date: Wed, 21 Feb 2024 15:04:41 +0000 Subject: [PATCH] cleanup(libsinsp): fix misaligned access to cmsghdr Signed-off-by: Luca Guerra --- userspace/libsinsp/parsers.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/userspace/libsinsp/parsers.cpp b/userspace/libsinsp/parsers.cpp index af83388f0c..6e4e919939 100644 --- a/userspace/libsinsp/parsers.cpp +++ b/userspace/libsinsp/parsers.cpp @@ -4151,8 +4151,9 @@ void sinsp_parser::parse_rw_exit(sinsp_evt *evt) parinfo = evt->get_param(4); if(parinfo->m_len > sizeof(cmsghdr)) { - cmsghdr *cmsg = (cmsghdr *)parinfo->m_val; - if(cmsg->cmsg_type == SCM_RIGHTS) + cmsghdr cmsg; + memcpy(&cmsg, parinfo->m_val, sizeof(cmsghdr)); + if(cmsg.cmsg_type == SCM_RIGHTS) { char error[SCAP_LASTERR_SIZE]; scap_threadinfo scap_tinfo {};