svn commit: r310877 - stable/11/contrib/bsnmp/snmpd

Ngie Cooper ngie at FreeBSD.org
Sat Dec 31 00:00:13 UTC 2016


Author: ngie
Date: Sat Dec 31 00:00:12 2016
New Revision: 310877
URL: https://svnweb.freebsd.org/changeset/base/310877

Log:
  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.

Modified:
  stable/11/contrib/bsnmp/snmpd/main.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/contrib/bsnmp/snmpd/main.c
==============================================================================
--- stable/11/contrib/bsnmp/snmpd/main.c	Fri Dec 30 23:59:43 2016	(r310876)
+++ stable/11/contrib/bsnmp/snmpd/main.c	Sat Dec 31 00:00:12 2016	(r310877)
@@ -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) {


More information about the svn-src-stable-11 mailing list