[PATCH] xodtemplate: segfault on contactgroup_members

Jeff iamirix at gmail.com
Fri May 10 17:43:19 CEST 2013


Hi all,

I discovered an issue with the latest version of Nagios from svn with my
company's configuration.  When a contactgroup definition contains both
members and contactgroup_members, Nagios segfaults when trying to verify
the configuration.  After some debugging, I came up with a solution that
appears to work for us.

The issue is that the when Nagios is "recombobulating" the
contactgroup_members, the call to strchr() is done with a null pointer,
because the loop with the existing controlling expression allows for an
extra iteration.  Switching the controlling expression to use next_ptr
allows the loop to exit when it should, because the last iteration's call
to strchr() returns a null pointer.  I'm not sure why it doesn't segfault
when specifying either members or contactgroup_members (not both), but my
solution appears to resolve the problem.

Forgive me if there's a different way to propose a patch, as this is my
first post to the list.  The (extremely simple) patch is as follows:

---

diff -ur a/xdata/xodtemplate.c b/xdata/xodtemplate.c
--- a/xdata/xodtemplate.c 2013-05-10 09:30:57.000000000 -0600
+++ b/xdata/xodtemplate.c 2013-05-10 09:31:01.000000000 -0600
@@ -6099,7 +6099,7 @@
  xodtemplate_contactgroup *cg;
  char *ptr, *next_ptr;

- for(next_ptr = ptr = temp_contactgroup->contactgroup_members; ptr; ptr =
next_ptr + 1) {
+ for(next_ptr = ptr = temp_contactgroup->contactgroup_members; next_ptr;
ptr = next_ptr + 1) {
  next_ptr = strchr(ptr, ',');
  if(next_ptr)
  *next_ptr = 0;


---



Cheers,
--
Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/developers/attachments/20130510/1e348a84/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and 
their applications. This 200-page book is written by three acclaimed 
leaders in the field. The early access version is available now. 
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
-------------- 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