Skip to content

Commit

Permalink
fix(libsinsp): resize the param storage in case of a long path
Browse files Browse the repository at this point in the history
Signed-off-by: Andrea Terzolo <[email protected]>
  • Loading branch information
Andreagit97 authored and poiana committed Jun 18, 2024
1 parent d0908f9 commit c3e482c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions userspace/libsinsp/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ sinsp_evt::sinsp_evt() :
m_flags(EF_NONE),
m_params_loaded(false),
m_info(NULL),
m_paramstr_storage(256),
m_paramstr_storage(1024),
m_resolved_paramstr_storage(1024),
m_tinfo(NULL),
m_fdinfo(NULL),
Expand Down Expand Up @@ -1019,9 +1019,14 @@ const char* sinsp_evt::get_param_as_str(uint32_t id, const char** resolved_str,
case PT_FSRELPATH:
{
std::string_view path = param->as<std::string_view>();
if(path.length() + 1 > m_paramstr_storage.size())
{
m_paramstr_storage.resize(path.length() + 1);
}

strcpy_sanitized(&m_paramstr_storage[0],
path.data(),
std::min(path.size() + 1, m_paramstr_storage.size()));
path.length() + 1);

sinsp_threadinfo* tinfo = get_thread_info();

Expand Down

0 comments on commit c3e482c

Please sign in to comment.