From 04457f5f16e705e1533ab06186f3cf3de86a8526 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 27 Jun 2023 12:53:08 +0200 Subject: [PATCH] IcingaDB::PrepareObject(): round Notification#times.{begin,end} not to crash Go daemon The latter expects ints, not floats - not to mention strings. Luckily Icinga already enforces numeric strings so that we can cast it to number. --- lib/icingadb/icingadb-objects.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/icingadb/icingadb-objects.cpp b/lib/icingadb/icingadb-objects.cpp index a475f4bb2..3687af752 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -1385,8 +1385,16 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a attributes->Set("timeperiod_id", GetObjectIdentifier(timeperiod)); if (notification->GetTimes()) { - attributes->Set("times_begin", notification->GetTimes()->Get("begin")); - attributes->Set("times_end",notification->GetTimes()->Get("end")); + auto begin (notification->GetTimes()->Get("begin")); + auto end (notification->GetTimes()->Get("end")); + + if (begin != Empty) { + attributes->Set("times_begin", std::round((double)begin)); + } + + if (end != Empty) { + attributes->Set("times_end", std::round((double)end)); + } } attributes->Set("notification_interval", std::max(0.0, std::round(notification->GetInterval())));