summaryrefslogtreecommitdiffstats
path: root/contrib/bsnmp
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2016-12-31 00:01:21 +0000
committerngie <ngie@FreeBSD.org>2016-12-31 00:01:21 +0000
commit61b3bdddde0fb2271943b6d849c31f977cc23344 (patch)
tree7d3681e5f853c9478e15fbd8ef455469893f1364 /contrib/bsnmp
parent550d1125c48ee924dc05e36dc31cf4768302bed4 (diff)
downloadFreeBSD-src-61b3bdddde0fb2271943b6d849c31f977cc23344.zip
FreeBSD-src-61b3bdddde0fb2271943b6d849c31f977cc23344.tar.gz
MFstable/11 r310877:
MFC r310455: 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.
Diffstat (limited to 'contrib/bsnmp')
-rw-r--r--contrib/bsnmp/snmpd/main.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/contrib/bsnmp/snmpd/main.c b/contrib/bsnmp/snmpd/main.c
index ea87127..cd9f0a5 100644
--- a/contrib/bsnmp/snmpd/main.c
+++ b/contrib/bsnmp/snmpd/main.c
@@ -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) {
OpenPOWER on IntegriCloud