Clarify failure in snmp_output(..) with call to snmp_pdu_decode
- Explicitly test snmp_pdu_encode against SNMP_CODE_OK instead of assuming any non-zero value is bad. - Print out the code before calling abort() to give the end-user something actionable to debug without having to recompile the binary, since the core might not have these details. MFC after: 1 week
This commit is contained in:
parent
eab80d9276
commit
f29369b7fb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=310455
@ -282,12 +282,13 @@ snmp_output(struct snmp_pdu *pdu, u_char *sndbuf, size_t *sndlen,
|
||||
const char *dest)
|
||||
{
|
||||
struct asn_buf resp_b;
|
||||
enum snmp_code code;
|
||||
|
||||
resp_b.asn_ptr = sndbuf;
|
||||
resp_b.asn_len = snmpd.txbuf;
|
||||
|
||||
if (snmp_pdu_encode(pdu, &resp_b) != 0) {
|
||||
syslog(LOG_ERR, "cannot encode message");
|
||||
if ((code = snmp_pdu_encode(pdu, &resp_b)) != SNMP_CODE_OK) {
|
||||
syslog(LOG_ERR, "cannot encode message (code=%d)", code);
|
||||
abort();
|
||||
}
|
||||
if (debug.dump_pdus) {
|
||||
|
Loading…
Reference in New Issue
Block a user