Skip to content

Commit

Permalink
IcingaDB::PrepareObject(): round Notification#times.{begin,end} not t…
Browse files Browse the repository at this point in the history
…o 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.
  • Loading branch information
Al2Klimov committed Jun 20, 2023
1 parent a3dabde commit c91dcf6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/icingadb/icingadb-objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1383,8 +1383,11 @@ 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"));

attributes->Set("times_begin", begin.GetType() == ValueEmpty ? begin : Value(std::round((double)begin)));
attributes->Set("times_end", end.GetType() == ValueEmpty ? end : Value(std::round((double)end)));
}

attributes->Set("notification_interval", notification->GetInterval());
Expand Down

0 comments on commit c91dcf6

Please sign in to comment.