Date: Mon, 27 Mar 2017 18:26:19 +0000 (UTC) From: Ngie Cooper <ngie@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r316043 - stable/11/contrib/bsnmp/lib Message-ID: <201703271826.v2RIQJhI018577@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: ngie Date: Mon Mar 27 18:26:19 2017 New Revision: 316043 URL: https://svnweb.freebsd.org/changeset/base/316043 Log: MFC r315641,r315642: r315641: bsnmp: don't leak snmp_client.fd in open_client_udp(..) on connect(2) failure r315642: bsnmp: explicitly test the return value for open_client_{local,udp} in snmp_open(..) open_client_* returns -1 on failure; 0 on success. Ensure that the return value is 0 -- otherwise exit snmp_open(..). Modified: stable/11/contrib/bsnmp/lib/snmpclient.c Directory Properties: stable/11/ (props changed) Modified: stable/11/contrib/bsnmp/lib/snmpclient.c ============================================================================== --- stable/11/contrib/bsnmp/lib/snmpclient.c Mon Mar 27 18:24:27 2017 (r316042) +++ stable/11/contrib/bsnmp/lib/snmpclient.c Mon Mar 27 18:26:19 2017 (r316043) @@ -947,6 +947,8 @@ open_client_udp(const char *host, const if ((res = res->ai_next) == NULL) { seterr(&snmp_client, "%s", strerror(errno)); freeaddrinfo(res0); + (void)close(snmp_client.fd); + snmp_client.fd = -1; return (-1); } } else @@ -1066,13 +1068,13 @@ snmp_open(const char *host, const char * switch (snmp_client.trans) { case SNMP_TRANS_UDP: - if (open_client_udp(host, port)) + if (open_client_udp(host, port) != 0) return (-1); break; case SNMP_TRANS_LOC_DGRAM: case SNMP_TRANS_LOC_STREAM: - if (open_client_local(host)) + if (open_client_local(host) != 0) return (-1); break;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703271826.v2RIQJhI018577>