|
1 # snmpd dumps core when snmpd.conf contains an incorrect logmatch param |
|
2 # Developed in-house. Bug submitted upstream |
|
3 # https://sourceforge.net/p/net-snmp/bugs/2591/ |
|
4 --- net-snmp-5.7.2.1/agent/mibgroup/ucd-snmp/logmatch.c Wed Feb 19 16:36:42 2014 |
|
5 +++ net-snmp-5.7.2.1/agent/mibgroup/ucd-snmp/logmatch.c Thu Oct 30 02:17:27 2014 |
|
6 @@ -435,6 +435,17 @@ |
|
7 regcomp(&(logmatchTable[logmatchCount].regexBuffer), |
|
8 logmatchTable[logmatchCount].regEx, |
|
9 REG_EXTENDED | REG_NOSUB); |
|
10 + if (logmatchTable[logmatchCount].myRegexError) |
|
11 + { |
|
12 + char regexErrorString[100]; |
|
13 + regerror(logmatchTable[logmatchCount].myRegexError, |
|
14 + &(logmatchTable[logmatchCount].regexBuffer), |
|
15 + regexErrorString, 100); |
|
16 + regexErrorString[99] = '\0'; |
|
17 + snmp_log(LOG_ERR, "Could not process the logmatch regex - %s," \ |
|
18 + "\n since regcomp() failed with - %s\n", |
|
19 + logmatchTable[logmatchCount].regEx, regexErrorString); |
|
20 + } |
|
21 |
|
22 if (logmatchTable[logmatchCount].frequency > 0) { |
|
23 snmp_alarm_register(logmatchTable[logmatchCount].frequency, |
|
24 @@ -469,8 +480,8 @@ |
|
25 */ |
|
26 |
|
27 for (i = 0; i < logmatchCount; i++) { |
|
28 - |
|
29 - regfree(&(logmatchTable[i].regexBuffer)); |
|
30 + if (logmatchTable[i].myRegexError == 0) |
|
31 + regfree(&(logmatchTable[i].regexBuffer)); |
|
32 } |
|
33 logmatchCount = 0; |
|
34 } |