]> granicus.if.org Git - icinga2/commitdiff
Log: Ensure not to pass negative values to localtime()
authorMichael Friedrich <michael.friedrich@icinga.com>
Wed, 16 Jan 2019 16:27:38 +0000 (17:27 +0100)
committerMichael Friedrich <michael.friedrich@icinga.com>
Mon, 11 Feb 2019 12:29:27 +0000 (13:29 +0100)
refs #6887

(cherry picked from commit 2fc33996b620d97e54d75b0d8c101fb3d9ba791c)

lib/icinga/checkable-check.cpp

index b159247a9aac96a5ca6aee9f328cb9308b7365ad..0b8917b77e8e77c6cbff6cd3075d37fce05f4c5b 100644 (file)
@@ -83,10 +83,11 @@ void Checkable::UpdateNextCheck(const MessageOrigin::Ptr& origin)
                adj = std::min(0.5 + fmod(GetSchedulingOffset(), interval * 5) / 100.0, adj);
 
        double nextCheck = now - adj + interval;
+       double lastCheck = GetLastCheck();
 
        Log(LogDebug, "Checkable")
                << "Update checkable '" << GetName() << "' with check interval '" << GetCheckInterval()
-               << "' from last check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", GetLastCheck())
+               << "' from last check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", (lastCheck < 0 ? 0 : lastCheck))
                << " (" << GetLastCheck() << ") to next check time at " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S %z", nextCheck) << "(" << nextCheck << ").";
 
        SetNextCheck(nextCheck, false, origin);