This seems bug-fix related and thus appropriate for 5.6.  +1 for me,
though I'd appreciate it if someone knowledgeable in the code stack  for
this table would look at it.


- ID: 3053436
Last Update: Attachment added ( takevos )
Details:

On some Linux systems the tcpListenerTable shows a random number in the
process id column.  After running valgrind on net-snmp I found that the
data structure (containing the process id) in the tcpListenerTable was
free-ed before it was used.

The _add_connection() function stores a pointer to this structure in the
tcpListenerTable. But the caller of _add_connection() frees this
structure after it has finished.

The fix involves copying the netsnmp_tcpconn_entry struct in
_add_connection, and add this copy as data into the tcpListenerTable.



--- agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.c      
(revision 123164)
+++ agent/mibgroup/tcp-mib/tcpListenerTable/tcpListenerTable_data_access.c      
(working copy)
@@ -169,15 +169,22 @@
 static void
 _add_connection(netsnmp_tcpconn_entry *entry, netsnmp_container *container)
 {
+    netsnmp_tcpconn_entry *new_entry;
     tcpListenerTable_rowreq_ctx *rowreq_ctx;
 
     DEBUGMSGTL(("tcpListenerTable:access", "creating new entry\n"));
 
+    /* Allocate a new entry, becuase the old entry will be destroyed by
+     * the function which called this one.
+     */
+    new_entry = netsnmp_access_tcpconn_entry_create();
+    (void)netsnmp_access_tcpconn_entry_update(new_entry, entry);
+
     /*
      * allocate an row context and set the index(es), then add it to
      * the container
      */
-    rowreq_ctx = tcpListenerTable_allocate_rowreq_ctx(entry, NULL);
+    rowreq_ctx = tcpListenerTable_allocate_rowreq_ctx(new_entry, NULL);
     if ((NULL != rowreq_ctx) &&
         (MFD_SUCCESS == tcpListenerTable_indexes_set(rowreq_ctx,
                                                      entry->loc_addr_len,
@@ -193,7 +200,7 @@
         } else {
             snmp_log(LOG_ERR, "memory allocation failed while loading "
                      "tcpListenerTable cache.\n");
-            netsnmp_access_tcpconn_entry_free(entry);
+            netsnmp_access_tcpconn_entry_free(new_entry);
         }
     }
 }


-- 
Wes Hardaker
Please mail all replies to [email protected]

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders
  • CFV: Wes Hardaker

Reply via email to