[icinga-checkins] icinga.org: icinga-nrpe/mfriedrich/fixes: don't free addrinfo always, but only if returned by getaddrinfo

git at icinga.org git at icinga.org
Sun Nov 13 15:02:09 CET 2011


Module: icinga-nrpe
Branch: mfriedrich/fixes
Commit: 90710393b3b6ae4302b05c0f1872c839d2d1fd27
URL:    https://git.icinga.org/?p=icinga-nrpe.git;a=commit;h=90710393b3b6ae4302b05c0f1872c839d2d1fd27

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Sun Nov 13 15:01:11 2011 +0100

don't free addrinfo always, but only if returned by getaddrinfo

this will prevent nrpe from segfaulting when checking for
allowed hosts.

---

 src/nrpe.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/nrpe.c b/src/nrpe.c
index 2d96d97..ee2f08f 100644
--- a/src/nrpe.c
+++ b/src/nrpe.c
@@ -1014,15 +1014,16 @@ int is_an_allowed_host(const struct sockaddr *connecting_host) {
 			for (r = res; r; r = r->ai_next) {
 				if (sockaddr_equal(r->ai_addr, connecting_host)) {
 					result = 1;
+					freeaddrinfo(res);
 					break;
 				}
 			}
 		}
 		if (result == 1) {
+			freeaddrinfo(res);
 			break;
 		}
 	}
-	freeaddrinfo(res);
 	return result;
 }
 





More information about the icinga-checkins mailing list