Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 31 Dec 2016 23:20:57 +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: r310988 - head/contrib/bsnmp/lib
Message-ID:  <201612312320.uBVNKvTF049456@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ngie
Date: Sat Dec 31 23:20:57 2016
New Revision: 310988
URL: https://svnweb.freebsd.org/changeset/base/310988

Log:
  snmp_discover_engine: fix up req/resp (PDU object) handling a bit
  
  - Call snmp_pdu_free on req and resp when done with the objects
  - Call snmp_pdu_free on req before calling snmp_pdu_create on it
    again
  
  MFC after:	1 week

Modified:
  head/contrib/bsnmp/lib/snmpclient.c

Modified: head/contrib/bsnmp/lib/snmpclient.c
==============================================================================
--- head/contrib/bsnmp/lib/snmpclient.c	Sat Dec 31 22:46:17 2016	(r310987)
+++ head/contrib/bsnmp/lib/snmpclient.c	Sat Dec 31 23:20:57 2016	(r310988)
@@ -1793,12 +1793,14 @@ snmp_discover_engine(char *passwd)
 		return (0);
 	}
 
+	snmp_pdu_free(&req);
+
 	snmp_pdu_create(&req, SNMP_PDU_GET);
 	req.engine.engine_boots = 0;
 	req.engine.engine_time = 0;
 
 	if (snmp_dialog(&req, &resp) == -1)
-		 return (-1);
+		return (-1);
 
 	if (resp.version != req.version) {
 		seterr(&snmp_client, "wrong version");
@@ -1813,6 +1815,9 @@ snmp_discover_engine(char *passwd)
 	snmp_client.engine.engine_boots = resp.engine.engine_boots;
 	snmp_client.engine.engine_time = resp.engine.engine_time;
 
+	snmp_pdu_free(&req);
+	snmp_pdu_free(&resp);
+
 	return (0);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612312320.uBVNKvTF049456>