From 0b578760c93779340450add953a9d0c5335c8109 Mon Sep 17 00:00:00 2001 From: Gerald Combs Date: Thu, 5 Oct 2023 16:49:55 -0700 Subject: [PATCH] fix(libsinsp): Add a couple of NULL checks Signed-off-by: Gerald Combs --- userspace/libsinsp/filterchecks.cpp | 5 +++++ userspace/libsinsp/parsers.cpp | 10 +++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/userspace/libsinsp/filterchecks.cpp b/userspace/libsinsp/filterchecks.cpp index 0ade8ca990..f84af85112 100644 --- a/userspace/libsinsp/filterchecks.cpp +++ b/userspace/libsinsp/filterchecks.cpp @@ -429,6 +429,11 @@ uint8_t* sinsp_filter_check_fspath::extract(sinsp_evt* evt, OUT uint32_t* len, b { sinsp_threadinfo* tinfo = evt->get_thread_info(); + if(tinfo == NULL) + { + return NULL; + } + std::filesystem::path tstr = tinfo->get_cwd() + m_tstr; m_tstr = std::filesystem::absolute(tstr).lexically_normal().string(); } diff --git a/userspace/libsinsp/parsers.cpp b/userspace/libsinsp/parsers.cpp index 91bc157e70..d28fd2be79 100644 --- a/userspace/libsinsp/parsers.cpp +++ b/userspace/libsinsp/parsers.cpp @@ -2807,7 +2807,15 @@ void sinsp_parser::parse_dirfd(sinsp_evt *evt, char* name, int64_t dirfd, OUT st } else if(dirfd == PPM_AT_FDCWD) { - *sdir = evt->m_tinfo->get_cwd(); + if(evt->m_tinfo != NULL) + { + *sdir = evt->m_tinfo->get_cwd(); + } + else + { + ASSERT(false); + *sdir = ""; + } } else {