java-topology/defects/nagioscore-0001/patch/nagioscore-0001.patch

54 lines
1.7 KiB
Diff

# UNDF: UNDF-2026-000000879
--- a/base/notifications.c
+++ b/base/notifications.c
@@ -82,6 +82,7 @@
extern notification *notification_list;
extern int notification_number;
+static dkhash_table *notification_hash = NULL;
/* Notification-related functions */
@@ -2104,9 +2105,10 @@
notification * find_notification(contact *cntct) {
notification *temp_notification = NULL;
- log_debug_info(DEBUGL_FUNCTIONS, 0, "find_notification() start\n");
-
- if(cntct == NULL)
+ if(cntct == NULL || cntct->name == NULL)
+ return NULL;
+
+ if(notification_hash != NULL)
+ return (notification *)dkhash_get(notification_hash, cntct->name, NULL);
return NULL;
for(temp_notification = notification_list; temp_notification != NULL; temp_notification = temp_notification->next) {
@@ -2124,6 +2126,8 @@
int add_notification(nagios_macros *mac, contact *cntct) {
notification *new_notification = NULL;
notification *temp_notification = NULL;
+ if(notification_hash == NULL)
+ notification_hash = dkhash_create(512);
log_debug_info(DEBUGL_FUNCTIONS, 0, "add_notification() start\n");
@@ -2146,6 +2150,7 @@
/* add new notification to head of list */
new_notification->next = notification_list;
notification_list = new_notification;
+ dkhash_insert(notification_hash, cntct->name, NULL, new_notification);
/* add contact to notification recipients macro */
if(mac->x[MACRO_NOTIFICATIONRECIPIENTS] == NULL)
@@ -2160,6 +2165,10 @@
void free_notification_list(void) {
notification *temp_notification = NULL;
notification *next_notification = NULL;
+ if(notification_hash != NULL) {
+ dkhash_destroy(notification_hash);
+ notification_hash = NULL;
+ }
temp_notification = notification_list;
while(temp_notification != NULL) {