mirror of
https://github.com/nmap/nmap.git
synced 2025-12-31 20:09:02 +00:00
Strip carriage returns (\r) from output to prevent spoofing
This commit is contained in:
@@ -462,7 +462,8 @@ static std::string escape_for_screen(const std::string s) {
|
||||
for (unsigned int i = 0; i < s.size(); i++) {
|
||||
char buf[5];
|
||||
unsigned char c = s[i];
|
||||
if (c == '\t' || c == '\r' || c == '\n' || (0x20 <= c && c <= 0x7e)) {
|
||||
// Printable and some whitespace ok. "\r" not ok because it overwrites the line.
|
||||
if (c == '\t' || c == '\n' || (0x20 <= c && c <= 0x7e)) {
|
||||
r += c;
|
||||
} else {
|
||||
Snprintf(buf, sizeof(buf), "\\x%02X", c);
|
||||
|
||||
Reference in New Issue
Block a user