Date: Fri, 23 Dec 2016 05:07:29 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310455 - head/contrib/bsnmp/snmpd Message-ID: <201612230507.uBN57Tln043571@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Fri Dec 23 05:07:28 2016 New Revision: 310455 URL: https://svnweb.freebsd.org/changeset/base/310455 Log: 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 Modified: head/contrib/bsnmp/snmpd/main.c Modified: head/contrib/bsnmp/snmpd/main.c ============================================================================== --- head/contrib/bsnmp/snmpd/main.c Fri Dec 23 05:02:17 2016 (r310454) +++ head/contrib/bsnmp/snmpd/main.c Fri Dec 23 05:07:28 2016 (r310455) @@ -282,12 +282,13 @@ snmp_output(struct snmp_pdu *pdu, u_char 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) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612230507.uBN57Tln043571>