--=-rIIrS3xBDWXuVJPMHf70
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

It seems as if netsnmp_container_table_unregister due to a mishap fails
to undo the actions of netsnmp_container_table_register.

The sequence leading up to the leak is as follows:

1. In the _register function netsnmp_container_table_handler_get is
called.
2. In the _get function a memory block is allocated and put in the
myvoid variable.
3. Back in the _register the "table_container" handler returned
from _get is injected into the handler chain and then the
netsnmp_register_table function is called.
4. In _register_table an "table" handler is injected in front of
the "table_container" handler and then netsnmp_register_handler
is called.
5. In _register_handler and "bulk_to_next" handler might be
injected in front of the handler that is provided.
6. Then all functions returns the value they get from the
subfunctions, so the return value of the _register function is
typically either a "bulk_to_next" handler or a "table" handler
Now comes unregister time - netsnmp_container_table_unregister is called
with the return value from _register. In unregister it is assumed that
the first handler of the reginfo points to the allocated object. As
detailed above this never happens and so there is a memory leak.

I thus think the attached patch should be applied to the agent, does
anyone disagree?

/MF

--=-rIIrS3xBDWXuVJPMHf70
Content-Disposition: attachment;
filename=netsnmp_container_table_unregister-uses-wrong-registry
Content-Type: text/x-patch;
name=netsnmp_container_table_unregister-uses-wrong-registry;
charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

Index: agent/helpers/table_container.c
================================================== =================
--- agent/helpers/table_container.c (revision 16865)
+++ agent/helpers/table_container.c (working copy)
@@ -323,7 +323,8 @@

if (!reginfo)
return MIB_UNREGISTRATION_FAILED;
- tad = (container_table_data *)reginfo->handler->myvoid;
+ tad = (container_table_data *)
+ netsnmp_find_handler_data_by_name(reginfo, "table_container");
if (tad) {
CONTAINER_FREE( tad->table );
tad->table = NULL;

--=-rIIrS3xBDWXuVJPMHf70
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--=-rIIrS3xBDWXuVJPMHf70
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/...et-snmp-coders

--=-rIIrS3xBDWXuVJPMHf70--