SF.net SVN: nagiosplug:[2236] nagiosplug/trunk/plugins/check_snmp.c

[email protected]
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
Revision: 2236
          http://nagiosplug.svn.sourceforge.net/nagiosplug/?rev=2236&view=rev
Author:   dermoth
Date:     2009-08-05 07:15:15 +0000 (Wed, 05 Aug 2009)

Log Message:
-----------
Fix segfault in check_snmp (definitive fix is still in the works - see bug #2832451)

From: Thomas Guyot-Sionnest <[email protected]>

Modified Paths:
--------------
    nagiosplug/trunk/plugins/check_snmp.c

Modified: nagiosplug/trunk/plugins/check_snmp.c
===================================================================
--- nagiosplug/trunk/plugins/check_snmp.c	2009-08-01 03:38:22 UTC (rev 2235)
+++ nagiosplug/trunk/plugins/check_snmp.c	2009-08-05 07:15:15 UTC (rev 2236)
@@ -186,7 +186,7 @@
 	}else{
 		snmpcmd = strdup (PATH_TO_SNMPGET);
 	}
-	
+
 	/* 9 arguments to pass before authpriv options + 1 for host and numoids. Add one for terminating NULL */
 	command_line = calloc (9 + numauthpriv + 1 + numoids + 1, sizeof (char *));
 	command_line[0] = snmpcmd;
@@ -255,15 +255,17 @@
 		ptr = chld_out.line[i];
 		oidname = strpcpy (oidname, ptr, delimiter);
 		response = strstr (ptr, delimiter);
+		if (response == NULL)
+			break;
+
 		if (verbose > 2) {
 			printf("Processing line %i\n  oidname: %s\n  response: %s\n", i+1, oidname, response);
 		}
 
-		/* We strip out the datatype indicator for PHBs */
-
 		/* Clean up type array - Sol10 does not necessarily zero it out */
 		bzero(type, sizeof(type));
 
+		/* We strip out the datatype indicator for PHBs */
 		if (strstr (response, "Gauge: "))
 			show = strstr (response, "Gauge: ") + 7;
 		else if (strstr (response, "Gauge32: "))


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.