diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 9096cdadcadaad29ffc7574cfb706ad61963d670..dcb31386478e9b191ed8864c8681362fdde0a6ed 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
}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;
/* This is just for display purposes, so it can remain a string */
asprintf(&cl_hidden_auth, "%s -t %d -r %d -m %s -v %s %s %s:%s",
- snmpcmd, timeout_interval, retries, miblist, proto, "[authpriv]",
+ snmpcmd, timeout_interval, retries, strlen(miblist) ? miblist : "''", proto, "[authpriv]",
server_address, port);
for (i = 0; i < numoids; i++) {
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 line: %s\n oidname: %s\n response: %s\n", i+1, ptr, oidname, response);
+ 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: "))
*/
needmibs = TRUE;
}
- oids = calloc(MAX_OIDS, sizeof (char *));
+ if (!oids) oids = calloc(MAX_OIDS, sizeof (char *));
for (ptr = strtok(optarg, ", "); ptr != NULL && j < MAX_OIDS; ptr = strtok(NULL, ", "), j++) {
oids[j] = strdup(ptr);
}
if ( needmibs == TRUE ) {
miblist = strdup (DEFAULT_MIBLIST);
}else{
- miblist = "''"; /* don't read any mib files for numeric oids */
+ miblist = ""; /* don't read any mib files for numeric oids */
}
}