Skip to content

Commit

Permalink
fix(userspace/libsinsp): avoid dereferencing a possible nullptr in pa…
Browse files Browse the repository at this point in the history
…rsers

Signed-off-by: Federico Di Pierro <[email protected]>
  • Loading branch information
FedeDP authored and poiana committed Sep 25, 2024
1 parent d4efc80 commit 227233b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions userspace/libsinsp/parsers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,20 +422,24 @@ void sinsp_parser::process_event(sinsp_evt *evt) {
case PPME_SYSCALL_MKDIRAT_X:
case PPME_SYSCALL_UNLINKAT_2_X:
case PPME_SYSCALL_MKNODAT_X: {
auto res = evt->get_param(0)->as<int64_t>();
if(res >= 0) {
// Only if successful
auto dirfd = evt->get_param(1)->as<int64_t>();
evt->set_fd_info(evt->get_tinfo()->get_fd(dirfd));
if (evt->get_tinfo() != nullptr) {
auto res = evt->get_param(0)->as<int64_t>();
if(res >= 0) {
// Only if successful
auto dirfd = evt->get_param(1)->as<int64_t>();
evt->set_fd_info(evt->get_tinfo()->get_fd(dirfd));
}
}
break;
}
case PPME_SYSCALL_SYMLINKAT_X: {
auto res = evt->get_param(0)->as<int64_t>();
if(res >= 0) {
// Only if successful
auto dirfd = evt->get_param(2)->as<int64_t>();
evt->set_fd_info(evt->get_tinfo()->get_fd(dirfd));
if (evt->get_tinfo() != nullptr) {
auto res = evt->get_param(0)->as<int64_t>();
if(res >= 0) {
// Only if successful
auto dirfd = evt->get_param(2)->as<int64_t>();
evt->set_fd_info(evt->get_tinfo()->get_fd(dirfd));
}
}
break;
}
Expand Down

0 comments on commit 227233b

Please sign in to comment.