Skip to content

Commit

Permalink
fix(libsinsp): return strings in syslog when they may be stack-allocated
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Guerra <[email protected]>
  • Loading branch information
LucaGuerra authored and poiana committed Nov 24, 2023
1 parent f72e40c commit 1cd1cc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions userspace/libsinsp/sinsp_syslog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void sinsp_syslog_decoder::parse_data(char *data, uint32_t len)
decode_message(data, len, pri, j);
}

const std::string& sinsp_syslog_decoder::get_severity_str() const
const std::string sinsp_syslog_decoder::get_severity_str() const
{
if(!is_data_valid() || m_severity >= sizeof(s_syslog_severity_strings) / sizeof(s_syslog_severity_strings[0]))
{
Expand All @@ -84,7 +84,7 @@ const std::string& sinsp_syslog_decoder::get_severity_str() const
}
}

const std::string& sinsp_syslog_decoder::get_facility_str() const
const std::string sinsp_syslog_decoder::get_facility_str() const
{
if(!is_data_valid() || m_facility >= sizeof(s_syslog_facility_strings) / sizeof(s_syslog_facility_strings[0]))
{
Expand Down Expand Up @@ -118,7 +118,7 @@ void sinsp_syslog_decoder::decode_message(char *data, uint32_t len, char* pristr
m_msg.assign(data + pristrlen + 2, len - pristrlen - 2);
}

const std::string& sinsp_syslog_decoder::get_info_line()
const std::string sinsp_syslog_decoder::get_info_line()
{
if (!is_data_valid())
{
Expand Down
8 changes: 4 additions & 4 deletions userspace/libsinsp/sinsp_syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ class sinsp_syslog_decoder

void parse_data(char *data, uint32_t len);

const std::string& get_info_line();
const std::string get_info_line();

const std::string& get_severity_str() const;
const std::string get_severity_str() const;

const std::string& get_facility_str() const;
const std::string get_facility_str() const;

inline void reset()
{
Expand All @@ -67,7 +67,7 @@ class sinsp_syslog_decoder
return m_severity;
}

inline const std::string& get_msg() const
inline const std::string get_msg() const
{
return m_msg;
}
Expand Down

0 comments on commit 1cd1cc1

Please sign in to comment.