[PATCH 2/2] nagios: Verify strdup() and nspath_absolute() return before proceed

Ricardo Jose Maraschini ricardo.maraschini at opservices.com.br
Thu Nov 29 17:52:20 CET 2012


From: Ricardo Maraschini <ricardo.maraschini at opservices.com.br>

Add verification on strdup() and nspath_absolute() returns before
proceed. In case of error on this early stage, exit with 
EXIT_FAILURE return code.

Signed-off-by: Ricardo Maraschini <ricardo.maraschini at opservices.com.br>

---
 base/nagios.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/base/nagios.c b/base/nagios.c
index bbc5a2f..5fd665e 100644
--- a/base/nagios.c
+++ b/base/nagios.c
@@ -440,6 +440,12 @@ int main(int argc, char **argv, char **env) {
 		else
 			nagios_binary_path = strdup(argv[0]);
 
+
+		if (!nagios_binary_path) {
+			logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Unable to allocate memory to copy nagios_binary_path\n");
+			exit(EXIT_FAILURE);
+		}
+
 		nagios_iobs = iobroker_create();
 
 		/* keep monitoring things until we get a shutdown command */
-- 
1.7.4.1



------------------------------------------------------------------------------
Keep yourself connected to Go Parallel: 
VERIFY Test and improve your parallel project with help from experts 
and peers. http://goparallel.sourceforge.net




More information about the Developers mailing list