From 992e4122804d4f2b092ce90ccd5d0d1f39a3a93c Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 27 Jun 2023 11:44:14 +0200 Subject: [PATCH] IcingaDB::PrepareObject(): cut off (null) negative Notification#times.{begin,end} not to crash Go daemon At least our PostgreSQL schema enforces positive values. --- 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 101c31bad88..2061ad6bca7 100644 --- a/lib/icingadb/icingadb-objects.cpp +++ b/lib/icingadb/icingadb-objects.cpp @@ -1386,8 +1386,8 @@ bool IcingaDB::PrepareObject(const ConfigObject::Ptr& object, Dictionary::Ptr& a auto begin (notification->GetTimes()->Get("begin")); auto end (notification->GetTimes()->Get("end")); - attributes->Set("times_begin", begin == Empty ? Empty : Value(std::round((double)begin))); - attributes->Set("times_end", end == Empty ? Empty : Value(std::round((double)end))); + attributes->Set("times_begin", begin == Empty || (double)begin < 0 ? Empty : Value(std::round((double)begin))); + attributes->Set("times_end", end == Empty || (double)end < 0 ? Empty : Value(std::round((double)end))); } attributes->Set("notification_interval", notification->GetInterval());