Merge branch 'V5-6-patches' into V5-7-patches
* V5-6-patches:
PATCH #1279: Modified patch from Mohan for coredump after calling free with a bad regex.
BUG #2521: AIX: dont die when CPU is dynamically added to system.
Complain about -D option if debugging is disabled.
diff --git a/agent/mibgroup/hardware/cpu/cpu_perfstat.c b/agent/mibgroup/hardware/cpu/cpu_perfstat.c
index 5f58190..5fdd531 100644
--- a/agent/mibgroup/hardware/cpu/cpu_perfstat.c
+++ b/agent/mibgroup/hardware/cpu/cpu_perfstat.c
@@ -90,7 +90,7 @@
strcpy( name.name, "");
if (perfstat_cpu(&name, cs2, sizeof(perfstat_cpu_t), n) > 0) {
for ( i = 0; i < n; i++ ) {
- cpu = netsnmp_cpu_get_byIdx( i, 0 );
+ cpu = netsnmp_cpu_get_byIdx( i, 1 );
cpu->user_ticks = (unsigned long long)cs2[i].user;
cpu->sys_ticks = (unsigned long long)cs2[i].sys + (unsigned long long)cs2[i].wait;
cpu->kern_ticks = (unsigned long long)cs2[i].sys;
diff --git a/agent/mibgroup/ucd-snmp/logmatch.c b/agent/mibgroup/ucd-snmp/logmatch.c
index ed08dc3..83b4e4a 100644
--- a/agent/mibgroup/ucd-snmp/logmatch.c
+++ b/agent/mibgroup/ucd-snmp/logmatch.c
@@ -432,17 +432,24 @@
*/
logmatchTable[logmatchCount].myRegexError =
- regcomp(&(logmatchTable[logmatchCount].regexBuffer),
+ regcomp(&logmatchTable[logmatchCount].regexBuffer,
logmatchTable[logmatchCount].regEx,
REG_EXTENDED | REG_NOSUB);
- if (logmatchTable[logmatchCount].frequency > 0) {
+ if (logmatchTable[logmatchCount].myRegexError) {
+ char regexErrorString[100];
+ regerror(logmatchTable[logmatchCount].myRegexError,
+ &logmatchTable[logmatchCount].regexBuffer,
+ regexErrorString, 100);
+ snmp_log(LOG_ERR, "Could not process the logmatch regex - %s," \
+ "\n since regcomp() failed with - %s\n",
+ logmatchTable[logmatchCount].regEx, regexErrorString);
+ }
+ else if (logmatchTable[logmatchCount].frequency > 0) {
snmp_alarm_register(logmatchTable[logmatchCount].frequency,
SA_REPEAT,
- (SNMPAlarmCallback *)
- updateLogmatch_Scheduled,
- &(logmatchTable[logmatchCount])
- );
+ (SNMPAlarmCallback *) updateLogmatch_Scheduled,
+ &logmatchTable[logmatchCount]);
}
logmatchCount++;
@@ -469,8 +476,8 @@
*/
for (i = 0; i < logmatchCount; i++) {
-
- regfree(&(logmatchTable[i].regexBuffer));
+ if (logmatchTable[i].myRegexError == 0)
+ regfree(&logmatchTable[i].regexBuffer);
}
logmatchCount = 0;
}
diff --git a/agent/snmpd.c b/agent/snmpd.c
index 574d890..cfc7bce 100644
--- a/agent/snmpd.c
+++ b/agent/snmpd.c
@@ -281,9 +281,11 @@
" -C\t\t\tdo not read the default configuration files\n",
get_configuration_directory(),
" -d\t\t\tdump sent and received SNMP packets\n"
+#ifndef NETSNMP_DISABLE_DEBUGGING
" -D[TOKEN[,...]]\tturn on debugging output for the given TOKEN(s)\n"
"\t\t\t (try ALL for extremely verbose output)\n"
"\t\t\t Don't put space(s) between -D and TOKEN(s).\n"
+#endif
" -f\t\t\tdo not fork from the shell\n",
#if HAVE_UNISTD_H
" -g GID\t\tchange to this numeric gid after opening\n"
@@ -580,8 +582,13 @@
break;
case 'D':
+#ifdef NETSNMP_DISABLE_DEBUGGING
+ fprintf(stderr, "Debugging not configured\n");
+ exit(1);
+#else
debug_register_tokens(optarg);
snmp_set_do_debugging(1);
+#endif
break;
case 'f':
diff --git a/snmplib/snmp_parse_args.c b/snmplib/snmp_parse_args.c
index a1c7353..6842d0e 100644
--- a/snmplib/snmp_parse_args.c
+++ b/snmplib/snmp_parse_args.c
@@ -124,8 +124,10 @@
" -t TIMEOUT\t\tset the request timeout (in seconds)\n");
fprintf(outf, "Debugging\n");
fprintf(outf, " -d\t\t\tdump input/output packets in hexadecimal\n");
+#ifndef NETSNMP_DISABLE_DEBUGGING
fprintf(outf,
" -D[TOKEN[,...]]\tturn on debugging output for the specified TOKENs\n\t\t\t (ALL gives extremely verbose debugging output)\n");
+#endif
fprintf(outf, "General options\n");
fprintf(outf,
" -m MIB[" ENV_SEPARATOR "...]\t\tload given list of MIBs (ALL loads everything)\n");
@@ -300,8 +302,13 @@
#endif /* NETSNMP_DISABLE_MIB_LOADING */
case 'D':
+#ifdef NETSNMP_NO_DEBUGGING
+ fprintf(stderr, "Debug not configured in\n");
+ return (NETSNMP_PARSE_ARGS_ERROR_USAGE);
+#else
debug_register_tokens(optarg);
snmp_set_do_debugging(1);
+#endif
break;
case 'd':