Skip to content

Commit

Permalink
fix(savefile-engine): skip unreferenced FD block
Browse files Browse the repository at this point in the history
If new threads come between scap_write_proclist and scap_write_fdlist,
we could have fdlist entries without their TID counterpart in the
proclist: silently skip them.
It would be nice to have a warning, but there aren't any in scap so I
won't risk adding one.

Signed-off-by: Angelo Puglisi <angelopuglisi86@gmail.com>
  • Loading branch information
deepskyblue86 authored and poiana committed Oct 19, 2022
1 parent 30c2498 commit 4f13d69
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions userspace/libscap/engine/savefile/scap_savefile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1531,12 +1531,6 @@ static int32_t scap_read_fdlist(scap_reader_t* r, uint32_t block_length, uint32_
// Identify the process descriptor
//
HASH_FIND_INT64(proclist->m_proclist, &tid, tinfo);
if(tinfo == NULL)
{
snprintf(error, SCAP_LASTERR_SIZE, "corrupted trace file. FD block references TID %"PRIu64", which doesn't exist.",
tid);
return SCAP_FAILURE;
}
}
else
{
Expand All @@ -1556,6 +1550,14 @@ static int32_t scap_read_fdlist(scap_reader_t* r, uint32_t block_length, uint32_
//
if(proclist->m_proc_callback == NULL)
{
if(tinfo == NULL)
{
//
// We have the fdinfo but no associated tid, skip it
//
continue;
}

//
// Parsed successfully. Allocate the new entry and copy the temp one into into it.
//
Expand Down

0 comments on commit 4f13d69

Please sign in to comment.