bug in finding a contact
Posted: Tue Jun 27, 2017 11:11 pm
The following bug (with the fix shown here) appears
in the find_contact_by_name_or_alias() routine in
Nagios 4.3.2 and various earlier releases:
With the present code, the contact is pretty much guaranteed not to
be found. If the correct contact name is given, it will be ignored.
And the alias is not likely to be identical to the name, so that will
be ignored as well. The corrected code recognizes when find_contact()
has found the desired contact, and returns that result.
I don't know how much of a difference fixing this will make, considering
for instance that on line 958 of base/checks.c, the service_notification()
routine is called with a NULL third parameter (for the not_author
argument of that routine). But perhaps there are other calls where it
might matter, or perhaps (I haven't checked any of this) that call might
now be modified to specify some particular author for the notification.
in the find_contact_by_name_or_alias() routine in
Nagios 4.3.2 and various earlier releases:
Code: Select all
nagios-4.3.2/base % diff -u notifications.c.orig notifications.c
--- notifications.c.orig 2017-05-09 10:03:31.000000000 -0700
+++ notifications.c 2017-06-27 20:41:48.332519925 -0700
@@ -36,7 +36,7 @@
{
contact *c = NULL;
- if (!name || !(c = find_contact(name)))
+ if (!name || (c = find_contact(name)))
return c;
for (c = contact_list; c; c = c->next)
if (!strcmp(c->alias, name))
be found. If the correct contact name is given, it will be ignored.
And the alias is not likely to be identical to the name, so that will
be ignored as well. The corrected code recognizes when find_contact()
has found the desired contact, and returns that result.
I don't know how much of a difference fixing this will make, considering
for instance that on line 958 of base/checks.c, the service_notification()
routine is called with a NULL third parameter (for the not_author
argument of that routine). But perhaps there are other calls where it
might matter, or perhaps (I haven't checked any of this) that call might
now be modified to specify some particular author for the notification.