From 1f7c38c792313c5e01dc41a5410645ef8fc6d1f3 Mon Sep 17 00:00:00 2001 From: Yannick Martin Date: Fri, 16 Jan 2026 18:14:46 +0100 Subject: [PATCH] Fix(#10687): address null pointer dereference on navigate --- lib/icinga/comment.ti | 10 ++++++---- lib/icinga/dependency.ti | 20 ++++++++++++-------- lib/icinga/downtime.ti | 10 ++++++---- lib/icinga/notification.ti | 10 ++++++---- lib/icinga/scheduleddowntime.ti | 10 ++++++---- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/lib/icinga/comment.ti b/lib/icinga/comment.ti index b8ad6f7f2..e51281b33 100644 --- a/lib/icinga/comment.ti +++ b/lib/icinga/comment.ti @@ -52,11 +52,13 @@ class Comment : ConfigObject < CommentNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/dependency.ti b/lib/icinga/dependency.ti index 41de7ba23..4c139078d 100644 --- a/lib/icinga/dependency.ti +++ b/lib/icinga/dependency.ti @@ -42,11 +42,13 @@ class Dependency : CustomVarObject < DependencyNameComposer } }}} navigate {{{ - if (GetChildServiceName().IsEmpty()) - return nullptr; + if (!GetChildServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetChildHostName()); + if (host) + return host->GetServiceByShortName(GetChildServiceName()); + } - Host::Ptr host = Host::GetByName(GetChildHostName()); - return host->GetServiceByShortName(GetChildServiceName()); + return nullptr; }}} }; @@ -69,11 +71,13 @@ class Dependency : CustomVarObject < DependencyNameComposer } }}} navigate {{{ - if (GetParentServiceName().IsEmpty()) - return nullptr; + if (!GetParentServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetParentHostName()); + if (host) + return host->GetServiceByShortName(GetParentServiceName()); + } - Host::Ptr host = Host::GetByName(GetParentHostName()); - return host->GetServiceByShortName(GetParentServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/downtime.ti b/lib/icinga/downtime.ti index 21e97313e..f6aeecd62 100644 --- a/lib/icinga/downtime.ti +++ b/lib/icinga/downtime.ti @@ -43,11 +43,13 @@ class Downtime : ConfigObject < DowntimeNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/notification.ti b/lib/icinga/notification.ti index 485360757..b7db178b5 100644 --- a/lib/icinga/notification.ti +++ b/lib/icinga/notification.ti @@ -61,11 +61,13 @@ class Notification : CustomVarObject < NotificationNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} }; diff --git a/lib/icinga/scheduleddowntime.ti b/lib/icinga/scheduleddowntime.ti index 1653f27e7..69a7153d5 100644 --- a/lib/icinga/scheduleddowntime.ti +++ b/lib/icinga/scheduleddowntime.ti @@ -44,11 +44,13 @@ class ScheduledDowntime : CustomVarObject < ScheduledDowntimeNameComposer } }}} navigate {{{ - if (GetServiceName().IsEmpty()) - return nullptr; + if (!GetServiceName().IsEmpty()) { + Host::Ptr host = Host::GetByName(GetHostName()); + if (host) + return host->GetServiceByShortName(GetServiceName()); + } - Host::Ptr host = Host::GetByName(GetHostName()); - return host->GetServiceByShortName(GetServiceName()); + return nullptr; }}} };