#
312050 |
|
13-Jan-2017 |
ngie |
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
|
#
300559 |
|
24-May-2016 |
ngie |
MFC r299764,r299765,r299767,r299769,r299770,r299774,r299802,r299803,r299805,r299814:
r299764:
Use the size of the destination buffer, not the source buffer.
Technically this is a no-op, but mute the clang warning in case the malloc call above for fstring ever changes in the future
r299765:
Fix theoretical buffer overflow issues in snmp_oid2asn_oid
Increase the size of `string` by 1 to account for the '\0' terminator. In the event that `str` doesn't contain any non-alpha chars, i would be set to MAXSTR, and the subsequent strlcpy call would overflow by a character.
Remove unnecessary `string[i] = '\0'` -- this is already handled by strlcpy.
r299767:
Mute sign compare warning by casting rc to u_int to match nbindings' type
rc cannot be negative -- that was already tested for earlier on in the function
r299769:
Use the size of the destination buffer instead of the malloc size, repeated, in order to mute a -Wstrlcpy-strlcat-size warning
r299770:
Fix up r299764
I meant to use nitems, not sizeof(..) with the destination buffer. Using sizeof(..) on a pointer will always truncate the output in the destination buffer incorrectly
Pointyhat to: ngie
r299774:
Do minimal work necessary to cure a -Wunused-but-set-variable warning from gcc
How errno is saved before and restored after strtoul calls needs a rethink
r299802:
Fix up both r299764 and r299770
nitems was wrong too, as it was being tested against a pointer instead of a buffer on the stack.
Since the old code was just doing malloc, then strlcpy'ing the contents of the source buffer into the destination buffer, replace it all with a call to strdup..
Supersized Duncecap to: ngie
r299803:
Replace malloc + memset(.., 0, ..) with calloc calls
r299805:
Fix up r299769
Similar to r299802, it was noted that using nitems on scalar pointers is invalid.
Use strdup instead of malloc + strlcpy (which is what the old code was doing anyhow).
Pointyhat to: ngie
r299814:
Replace malloc + memset(.., 0, ..) with calloc calls
|