Hi,
On Solaris, whenever there is a wrong regex as logmatch parameter, when
the corresponding structures are being de-allocated, snmpd coredumps.
This is because we are freeing the structures using regfree(), even when
the corresponding regcomp() returns with an error. The attached patch
fixes the issue.
Can someone evaluate the patch?
Thanks!
-- Mohan.
--- 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
@@ -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;
}
@@ -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,
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders