MCPcopy Create free account
hub / github.com/CleverRaven/Cataclysm-DDA / debug_is_safe_string

Function debug_is_safe_string

src/debug.cpp:811–824  ·  view source on GitHub ↗

Verify that a string is safe for passing as an argument to addr2line. In particular, we want to avoid any characters of significance to the shell.

Source from the content-addressed store, hash-verified

809// Verify that a string is safe for passing as an argument to addr2line.
810// In particular, we want to avoid any characters of significance to the shell.
811static bool debug_is_safe_string( const char *start, const char *finish )
812{
813 static constexpr char safe_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
814 "abcdefghijklmnopqrstuvwxyz"
815 "01234567890_./-+";
816 using std::begin;
817 using std::end;
818 const auto is_safe_char =
819 [&]( char c ) {
820 const char *in_safe = std::find( begin( safe_chars ), end( safe_chars ), c );
821 return c && in_safe != end( safe_chars );
822 };
823 return std::all_of( start, finish, is_safe_char );
824}
825
826static std::string debug_resolve_binary( const std::string &binary, std::ostream &out )
827{

Callers 1

debug_write_backtraceFunction · 0.85

Calls 2

beginFunction · 0.70
endFunction · 0.70

Tested by

no test coverage detected