Skip to content

Commit c21e99a

Browse files
Al2Klimovyhabteab
authored andcommitted
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.
1 parent 14b854d commit c21e99a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/icingadb/icingadb-objects.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2651,8 +2651,8 @@ Dictionary::Ptr IcingaDB::SerializeState(const Checkable::Ptr& checkable)
26512651

26522652
if (!cr->GetCommand().IsEmpty())
26532653
attrs->Set("check_commandline", FormatCommandLine(cr->GetCommand()));
2654-
attrs->Set("execution_time", TimestampToMilliseconds(fmax(0.0, cr->CalculateExecutionTime())));
2655-
attrs->Set("latency", TimestampToMilliseconds(cr->CalculateLatency()));
2654+
attrs->Set("execution_time", std::min((long long)UINT32_MAX, TimestampToMilliseconds(fmax(0.0, cr->CalculateExecutionTime()))));
2655+
attrs->Set("latency", std::min((long long)UINT32_MAX, TimestampToMilliseconds(cr->CalculateLatency())));
26562656
attrs->Set("check_source", cr->GetCheckSource());
26572657
attrs->Set("scheduling_source", cr->GetSchedulingSource());
26582658
}

0 commit comments

Comments
 (0)