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.
| 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. |
| 811 | static 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 | |
| 826 | static std::string debug_resolve_binary( const std::string &binary, std::ostream &out ) |
| 827 | { |
no test coverage detected