<div dir="ltr">Hi all,<div><br></div><div>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.</div>
<div><br></div><div>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.</div>
<div><br></div><div style>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:</div><div style><br></div><div style>---</div><div style>
<div><br></div><div>diff -ur a/xdata/xodtemplate.c b/xdata/xodtemplate.c </div><div>--- a/xdata/xodtemplate.c<span class="" style="white-space:pre"> </span>2013-05-10 09:30:57.000000000 -0600</div><div>+++ b/xdata/xodtemplate.c<span class="" style="white-space:pre"> </span>2013-05-10 09:31:01.000000000 -0600</div>
<div>@@ -6099,7 +6099,7 @@</div><div> <span class="" style="white-space:pre"> </span>xodtemplate_contactgroup *cg;</div><div> <span class="" style="white-space:pre"> </span>char *ptr, *next_ptr;</div><div> </div><div>
-<span class="" style="white-space:pre"> </span>for(next_ptr = ptr = temp_contactgroup->contactgroup_members; ptr; ptr = next_ptr + 1) {</div><div>+<span class="" style="white-space:pre"> </span>for(next_ptr = ptr = temp_contactgroup->contactgroup_members; next_ptr; ptr = next_ptr + 1) {</div>
<div> <span class="" style="white-space:pre"> </span>next_ptr = strchr(ptr, ',');</div><div> <span class="" style="white-space:pre"> </span>if(next_ptr)</div><div> <span class="" style="white-space:pre"> </span>*next_ptr = 0;</div>
<div><br></div></div><div><br></div><div>---</div><div><br></div><div><br></div><div><br></div><div>Cheers,<br clear="all"><div>--<br>Jeff</div>
</div></div>