Hi,

I found a NULL pointer issue while trap sending in case of memory limitation.
This error is in all net-snmp version I checked: V5.4.4 till current trunk.
Is this a possible solution?

Best regards,
Claus

diff --git a/agent/agent_trap.c b/agent/agent_trap.c
index 080b8bf..9613966 100644
--- a/agent/agent_trap.c
+++ b/agent/agent_trap.c
@@ -919,8 +919,14 @@ send_trap_to_sess(netsnmp_session * sess, netsnmp_pdu 
*template_pdu)
         (template_pdu->command == SNMP_MSG_TRAP))
         return;                 /* Skip v2+ sinks for v1 only traps */
 #endif
+
     template_pdu->version = sess->version;
     pdu = snmp_clone_pdu(template_pdu);
+    if(!pdu) {
+        snmp_log(LOG_WARNING, "send_trap: failed to clone PDU\n");
+        return;
+    }
+
     pdu->sessid = sess->sessid; /* AgentX only ? */
 
     if ( template_pdu->command == SNMP_MSG_INFORM
@@ -930,7 +936,6 @@ send_trap_to_sess(netsnmp_session * sess, netsnmp_pdu 
*template_pdu)
        ) {
         result =
             snmp_async_send(sess, pdu, &handle_inform_response, NULL);
-        
     } else {
         if ((sess->version == SNMP_VERSION_3) &&
                 (pdu->command == SNMP_MSG_TRAP2) &&



------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to