From c21e99a15c030078d9bc6c0ff16c3dd43e4d3e51 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 15 May 2024 12:55:41 +0200 Subject: [PATCH] IcingaDB#SerializeState(): limit execution_time and latency to 2^32-1 not to write higher values into Redis than the Icinga DB schema can hold. This fixes yet another potential Go daemon crash. --- lib/icingadb/icingadb-objects.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index 6322743ec..920251969 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -2651,8 +2651,8 @@ Dictionary::Ptr IcingaDB::SerializeState(const Checkable::Ptr& checkable) if (!cr->GetCommand().IsEmpty()) attrs->Set("check_commandline", FormatCommandLine(cr->GetCommand())); - attrs->Set("execution_time", TimestampToMilliseconds(fmax(0.0, cr->CalculateExecutionTime()))); - attrs->Set("latency", TimestampToMilliseconds(cr->CalculateLatency())); + attrs->Set("execution_time", std::min((long long)UINT32_MAX, TimestampToMilliseconds(fmax(0.0, cr->CalculateExecutionTime())))); + attrs->Set("latency", std::min((long long)UINT32_MAX, TimestampToMilliseconds(cr->CalculateLatency()))); attrs->Set("check_source", cr->GetCheckSource()); attrs->Set("scheduling_source", cr->GetSchedulingSource()); }