On Thu, Jan 12, 2012 at 12:14 PM, Jan Safranek <jsafr...@redhat.com> wrote:

> If the netsnmp_register_mib() function returns error, sometimes it frees
> its reginfo argument (agent_registry.c:1136) and sometimes not
> (agent_registry.c:1164). The caller does not know what to do and in most
> cases frees reginfo again (e.g. hrSWInstalledTable.c:144 and :166).
>
> I'd guess that netsnmp_register_mib() should not free its arguments, but
> I want to know your opinion first - I don't dare to touch these parts of
> agent without a review.
>
> BTW, there are *lot of* cases when return value of
> netsnmp_register_mib() is not checked at all, e.g.
> mibgroup/agent/extend.c:198 and serious rewrite is needed.
>

My proposal is not to change anything in netsnmp_register_mib() unless you
can construct a (unit) test program that shows that netsnmp_register_mib()
behaves incorrectly. It took me a lot of time and effort to make sure that
that function neither triggers a crash nor triggers a memory leak on Linux
and Windows. I'm not looking forward to repeat all that testing.

By the way, running "make test" on Linux does not trigger the error paths
in netsnmp_register_mib(). So if you want to change anything in that
function the first step is to add a unit test in
testing/testing/fulltests/unit-tests that triggers all error paths. And
once such a unit test has been developed you should make sure that it
doesn't trigger any Valgrind complaints - neither invalid memory acceses
nor memory leaks.

Bart.
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to