Page 1 of 1

[Nagios-devel] [patch] Add check for NULL for event_list_high

Posted: Wed Oct 21, 2009 12:54 am
by Guest
This is a multi-part message in MIME format.
--------------080703040305030105090607
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

I was playing with the source for my own pleasure and discovered what
could be a bug.

"event_list_high" is a chained list for high priority events.

When Nagios
- Pops the next event to be executed from the list,
- Sets the new head of the list to the next event using the "next"
pointer of the current event and
- Assigns NULL to the "prev" pointer of the new event at the head

it does not verify if this new head isn't NULL (being therefore at the
end of the chained list) before trying to update the "prev" pointer.

Nagios does check for NULL when dealing with the list "event_list_low"
but not with "event_list_high".

Attached is a patch fixing this potential bug.

--
Mathieu

--------------080703040305030105090607
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name="nagios-null-event_list_high.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="nagios-null-event_list_high.patch"

diff -Naur nagios-HEAD.orig/base/events.c nagios-HEAD/base/events.c
--- nagios-HEAD.orig/base/events.c 2009-06-16 23:23:38.000000000 -0400
+++ nagios-HEAD/base/events.c 2009-10-20 21:26:03.000000000 -0400
@@ -996,7 +996,9 @@
/* remove the first event from the timing loop */
temp_event=event_list_high;
event_list_high=event_list_high->next;
- event_list_high->prev=NULL;
+ /* we may have just removed the only item from the list */
+ if (event_list_high!=NULL)
+ event_list_high->prev=NULL;

/* handle the event */
handle_timed_event(temp_event);

--------------080703040305030105090607--





This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]