[PATCH 1/1] snmp_agent: Fixes incrementation of snmpInTotalSetVars

Michael Schmidt via Net-snmp-coders <[email protected]> Fri, 28 Feb 2025 14:14:50 +0100
Newsgroups gmane.network.net-snmp.devel
Message-ID <[email protected]>
From: scmi <[email protected]>

Implements a temporary variable 'command' which saves the value of the command-pointer before modifications for a later value check.

Signed-off-by: Michael Schmidt <[email protected]>
---
 agent/snmp_agent.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/agent/snmp_agent.c b/agent/snmp_agent.c
index 9913a968e1..c728059ac8 100644
--- a/agent/snmp_agent.c
+++ b/agent/snmp_agent.c
@@ -1908,6 +1908,8 @@ netsnmp_wrap_up_request(netsnmp_agent_session *asp, int status)
     }
 
     if (asp->pdu) {
+	int command = asp->pdu->command;
+
         /*
          * If we've got an error status, then this needs to be
          *  passed back up to the higher levels....
@@ -2030,7 +2032,7 @@ netsnmp_wrap_up_request(netsnmp_agent_session *asp, int status)
         if (status == SNMP_ERR_NOERROR)
             snmp_increment_statistic_by(
 #ifndef NETSNMP_NO_WRITE_SUPPORT
-                (asp->pdu->command == SNMP_MSG_SET ?
+                (command == SNMP_MSG_SET ?
                  STAT_SNMPINTOTALSETVARS : STAT_SNMPINTOTALREQVARS),
 #else
                 STAT_SNMPINTOTALREQVARS,
-- 
2.39.5