[PATCH] Fix event broker callback functions self de-registering for callbacks

Sean Millichamp sean at bruenor.org
Fri Oct 30 22:27:16 CET 2009


Hello everyone,

I stumbled into this while debugging the relatively new Merlin event
broker module.  It resulted in a segfault and took a while to hunt down.

If a Nagios event broker callback function de-registers itself (via
neb_deregister_callback) while it is being called (from
neb_make_callbacks) there is a pointer problem.

neb_make_callbacks walks the callback linked list like this:

for(temp_callback=neb_callback_list[callback_type];temp_callback!=NULL;temp_callback=temp_callback->next){
	callbackfunc=temp_callback->callback_func;
	cbresult=callbackfunc(callback_type,data);
}

If callbackfunc() calls neb_deregister_callback then the memory address
pointed to by temp_callback is free()d and no longer valid, making the
temp_callback=temp_callback->next not valid (though if the memory hasn't
been overwritten yet it may work).

I have attached a simple patch which I believe addresses the issues and
makes it safe to let the callback functions de-register themselves.

Thanks,
Sean

-------------- next part --------------
A non-text attachment was scrubbed...
Name: nagios-fix-callback-self-deregistering.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20091030/9ba03779/attachment.bin>
-------------- next part --------------
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
-------------- next part --------------
_______________________________________________
Nagios-devel mailing list
Nagios-devel at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-devel


More information about the Developers mailing list