From 2cdf5cb6d9b176a49b1f3588ca55c241f6a6c3e3 Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Tue, 26 Mar 2019 12:00:00 +0100 Subject: Stop checking for too old or too new timestamp. Don't allow pid field to end with trailing slash when no thread id is present. --- vespalog/src/vespa/log/log_message.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'vespalog') diff --git a/vespalog/src/vespa/log/log_message.cpp b/vespalog/src/vespa/log/log_message.cpp index 6e3584bafc3..ec734747dbc 100644 --- a/vespalog/src/vespa/log/log_message.cpp +++ b/vespalog/src/vespa/log/log_message.cpp @@ -4,6 +4,7 @@ #include "exceptions.h" #include #include +#include namespace ns_log { @@ -41,17 +42,6 @@ parse_time_field(std::string time_field) os << "Bad time field: " << time_field; throw BadLogLineException(os.str()); } - time_t now = time(nullptr); - if (logtime - 864000 > now) { - std::ostringstream os; - os << "time > 10 days in the future: " << time_field; - throw BadLogLineException(os.str()); - } - if (logtime + 8640000 < now) { - std::ostringstream os; - os << "time > 100 days in the past: " << time_field; - throw BadLogLineException(os.str()); - } return logtime * 1000000000; } @@ -70,11 +60,16 @@ PidFieldParser::PidFieldParser(std::string pid_field) std::istringstream pid_stream(pid_field); pid_stream.imbue(clocale); pid_stream >> _process_id; + bool badField = false; if (!pid_stream.eof() && pid_stream.good() && pid_stream.peek() == '/') { pid_stream.get(); - pid_stream >> _thread_id; + if (pid_stream.eof()) { + badField = true; + } else { + pid_stream >> _thread_id; + } } - if (!pid_stream.eof() || pid_stream.fail() || pid_stream.bad()) { + if (!pid_stream.eof() || pid_stream.fail() || pid_stream.bad() || badField) { std::ostringstream os; os << "Bad pid field: " << pid_field; throw BadLogLineException(os.str()); -- cgit v1.2.3