[nagiosplug] check_host: Allocate a large-enough buffer for ...

Thomas Guyot-Sionnest dermoth at users.sourceforge.net
Fri Apr 29 02:48:11 CEST 2011


    Module: nagiosplug
    Branch: master
    Commit: 5ebe25fc24d33cf2d7b46fce9e746a58e0115010
    Author: Sebastian Harl <sh at teamix.net>
 Committer: Thomas Guyot-Sionnest <dermoth at aei.ca>
      Date: Thu Apr 28 09:18:21 2011 +0200
       URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=5ebe25f

check_host: Allocate a large-enough buffer for the host table.

When specifying a host-name on the command line, each of its IPs is added to
the host table (and each one is pinged). So, the buffer has to be large enough
to hold all of the respective host objects. (argc - 1) only fits hosts with a
single IP.

Thanks to Max Kosmach <max at tcen.ru> for reporting this in Debian bug #623702.

---

 NEWS                      |    1 +
 THANKS.in                 |    1 +
 plugins-root/check_icmp.c |    2 +-
 3 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/NEWS b/NEWS
index fcaa9c1..8bb0fcb 100644
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ This file documents the major additions and syntax changes between releases.
 	Make check_snmp work more like v1.4.14 with regard to using special values (Timeticks, STRING) as numeric thresholds
 	Fix check_ldap overriding the port when --ssl was specified after -p
 	Fix check_procs where regex input of '|' would get displayed in output - now replaced with ','
+	Fix segfault in check_host when hostname returns multiple IP addresses (Sebastian Harl)
 
 1.4.15 27th July 2010
 	ENHANCEMENTS
diff --git a/THANKS.in b/THANKS.in
index cb8d26c..c6775bc 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -268,3 +268,4 @@ Brian Landers
 Ryan Kelly
 Stéphane Urbanovski
 Marco Beck
+Sebastian Harl
diff --git a/plugins-root/check_icmp.c b/plugins-root/check_icmp.c
index 6d8ba09..fe8fc56 100644
--- a/plugins-root/check_icmp.c
+++ b/plugins-root/check_icmp.c
@@ -621,7 +621,7 @@ main(int argc, char **argv)
 	}
 
 	host = list;
-	table = malloc(sizeof(struct rta_host **) * (argc - 1));
+	table = malloc(sizeof(struct rta_host **) * targets);
 	i = 0;
 	while(host) {
 		host->id = i*packets;





More information about the Commits mailing list