17812413 net-snmp 5.4.1 dumps core when snmpd.conf contains an incorrect logmatch param. s11-update
authorMohana Rao Gorai <mohana.gorai@oracle.com>
Fri, 28 Mar 2014 18:50:36 -0700
branchs11-update
changeset 3023 90190872ae3e
parent 3021 b9308977c65b
child 3024 17605ce48f74
17812413 net-snmp 5.4.1 dumps core when snmpd.conf contains an incorrect logmatch param.
components/net-snmp/patches/040.17812413.logmatch_free.patch
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/net-snmp/patches/040.17812413.logmatch_free.patch	Fri Mar 28 18:50:36 2014 -0700
@@ -0,0 +1,33 @@
+# This patch has been submitted upstream. But it has not been accepted yet.
+
+--- a/agent/mibgroup/ucd-snmp/logmatch.c	Thu Sep 14 17:48:50 2006
++++ b/agent/mibgroup/ucd-snmp/logmatch.c	Wed Feb  5 23:56:38 2014
[email protected]@ -118,8 +118,8 @@
+      */
+ 
+     for (i = 0; i < logmatchCount; i++) {
+-
+-        regfree(&(logmatchTable[i].regexBuffer));
++        if (logmatchTable[i].myRegexError == 0)
++            regfree(&(logmatchTable[i].regexBuffer));
+     }
+     logmatchCount = 0;
+ }
[email protected]@ -212,6 +212,17 @@
+             regcomp(&(logmatchTable[logmatchCount].regexBuffer),
+                     logmatchTable[logmatchCount].regEx,
+                     REG_EXTENDED | REG_NOSUB);
++		if (logmatchTable[logmatchCount].myRegexError)
++		{
++			char regexErrorString[100];
++			regerror(logmatchTable[logmatchCount].myRegexError,
++					&(logmatchTable[logmatchCount].regexBuffer),
++					regexErrorString, 100);
++			regexErrorString[99] = '\0';
++			snmp_log(LOG_ERR, "Could not process the logmatch regex - %s," \
++					"\n since regcomp() failed with - %s\n",
++					logmatchTable[logmatchCount].regEx, regexErrorString);
++		}
+ 
+         if (logmatchTable[logmatchCount].frequency > 0) {
+             snmp_alarm_register(logmatchTable[logmatchCount].frequency,