Blame SOURCES/net-snmp-5.7.2-trigger-crash.patch

9a6c41
1050971 - snmpd segfault with entry->sysUpTime = *sysUT_var.val.integer
9a6c41
9a6c41
commit 9f4c572614091404decba0d4ef1a4cbaf9fc5bd2
9a6c41
Author: Jan Safranek <jsafranek@users.sourceforge.net>
9a6c41
Date:   Thu Jan 9 13:35:27 2014 +0100
9a6c41
9a6c41
    CHANGES: snmpd: Fixed monitoring based on non-delta trigger.
9a6c41
    
9a6c41
    snmpd crashed wit following snmpd.conf:
9a6c41
        monitor -s -D -r 10 -e LOGMATCH -o logMatchCurrentCount "Log Match" != logMatchCurrentCount
9a6c41
        logmatch LoginFailure1 /var/log/secure 10 su: .*fail.*
9a6c41
    
9a6c41
    The reason was unitialized variable sysUT_var in mteTrigger_run(), it was
9a6c41
    filled only if the trigger was delta-valued, while its value was used for all
9a6c41
    triggers.
9a6c41
    
9a6c41
    With this patch, sysUT_var is filled for all code branches where it is needed.
9a6c41
9a6c41
diff --git a/agent/mibgroup/disman/event/mteTrigger.c b/agent/mibgroup/disman/event/mteTrigger.c
9a6c41
index bb585ed..11cb5b7 100644
9a6c41
--- a/agent/mibgroup/disman/event/mteTrigger.c
9a6c41
+++ b/agent/mibgroup/disman/event/mteTrigger.c
9a6c41
@@ -533,6 +533,13 @@ mteTrigger_run( unsigned int reg, void *clientarg)
9a6c41
         } /* !old_results - end of else block */
9a6c41
     } /* MTE_TRIGGER_EXISTENCE */
9a6c41
 
9a6c41
+    /*
9a6c41
+     * We'll need sysUpTime.0 regardless...
9a6c41
+     */
9a6c41
+    DEBUGMSGTL(("disman:event:delta", "retrieve sysUpTime.0\n"));
9a6c41
+    memset( &sysUT_var, 0, sizeof( netsnmp_variable_list ));
9a6c41
+    snmp_set_var_objid( &sysUT_var, _sysUpTime_instance, _sysUpTime_inst_len );
9a6c41
+    netsnmp_query_get(  &sysUT_var, entry->session );
9a6c41
 
9a6c41
     if (( entry->mteTriggerTest & MTE_TRIGGER_BOOLEAN   ) ||
9a6c41
         ( entry->mteTriggerTest & MTE_TRIGGER_THRESHOLD )) {
9a6c41
@@ -582,14 +589,6 @@ mteTrigger_run( unsigned int reg, void *clientarg)
9a6c41
          * (including sysUpTime.0 if not specified explicitly).
9a6c41
          */
9a6c41
         if ( entry->flags & MTE_TRIGGER_FLAG_DELTA ) {
9a6c41
-            /*
9a6c41
-             * We'll need sysUpTime.0 regardless...
9a6c41
-             */
9a6c41
-            DEBUGMSGTL(("disman:event:delta", "retrieve sysUpTime.0\n"));
9a6c41
-            memset( &sysUT_var, 0, sizeof( netsnmp_variable_list ));
9a6c41
-            snmp_set_var_objid( &sysUT_var, _sysUpTime_instance,
9a6c41
-                                            _sysUpTime_inst_len );
9a6c41
-            netsnmp_query_get(  &sysUT_var, entry->session );
9a6c41
 
9a6c41
             if (!(entry->flags & MTE_TRIGGER_FLAG_SYSUPT)) {
9a6c41
                 /*