Skip to content

Commit

Permalink
Properly set length for extracted filenames. (#630)
Browse files Browse the repository at this point in the history
While merging together #624 (multi string search) and #625 (don't
sanitize strings), the length was only being set when string
sanitization was enabled.

Additionally, the length was not being initialized to 0, meaning that it
was not defined.

This led to some FPs for some of the falco tests.
  • Loading branch information
gianlucaborello committed Aug 16, 2016
1 parent 10a5e33 commit 26eca3b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions userspace/libsinsp/filterchecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,11 @@ uint8_t* sinsp_filter_check_fd::extract(sinsp_evt *evt, OUT uint32_t* len)
m_tstr = m_fdinfo->m_name;
}

sanitize_string(m_tstr);
if(sanitize_strings)
{
sanitize_string(m_tstr);
}
*len = m_tstr.size();

return (uint8_t*)m_tstr.c_str();
case TYPE_FDTYPE:
if(m_fdinfo == NULL)
Expand Down Expand Up @@ -1249,8 +1251,9 @@ bool sinsp_filter_check_fd::compare(sinsp_evt *evt)
//
// Standard extract-based fields
//
uint32_t len;
uint8_t* extracted_val = extract(evt, &len);
uint32_t len = 0;
bool sanitize_strings = false;
uint8_t* extracted_val = extract(evt, &len, sanitize_strings);

if(extracted_val == NULL)
{
Expand Down

0 comments on commit 26eca3b

Please sign in to comment.