]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r310892,r310894,r310989:
authorngie <ngie@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 13 Jan 2017 08:59:22 +0000 (08:59 +0000)
committerngie <ngie@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 13 Jan 2017 08:59:22 +0000 (08:59 +0000)
commit610ff956e240dc4b6b21e494699cb22a77050c0c
tree3328baf8034341000b9c32b295dfb2526309dd13
parent7b8e2f5a1b638e611975f63e7f1cc1413ed8f9c7
MFC r310892,r310894,r310989:

r310892:

Don't call snmp_pdu_free(..) until finished with the pdu and when ready to
allocate a new one via snmp_pdu_create(..)

This fixes bsnmpwalk, so it no longer crashes after r310729

r310894:

snmp_pdu_free the right object at the right time in snmptool_walk

r310892 was on the right track, but unfortunately it was resolving
the problem incorrectly and accidentally leaking memory in the
process.

- Call snmp_pdu_free on req before calling snmp_pdu_create on it
  at the bottom of the outer while loop
- Call snmp_pdu_free on resp after calling snmpwalk_nextpdu_create
  in the inner loop

r310989:

Call snmp_pdu_free on req/resp with a consistent, correct pattern

- snmp_pdu_free should be called before snmp_pdu_create is called
  again
- snmp_pdu_free should be called on the resp to snmp_dialog when
  successful

Tested with the following bsnmp commands:

  % export SNMPUSER=bsnmp SNMPPASSWD=bsnmptest
  % SNMP_ARGS="-A proto=sha -C context='' -K -P proto=des -v 3 -r 0"
  % bsnmpset $SNMP_ARGS sysLocation="MyAgent"
  % bsnmpget $SNMP_ARGS sysLocation
  % bsnmpwalk $SNMP_ARGS

git-svn-id: svn://svn.freebsd.org/base/stable/10@312050 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
usr.sbin/bsnmpd/tools/bsnmptools/bsnmpget.c