summaryrefslogtreecommitdiffstats
path: root/contrib/bsnmp/lib
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2017-03-27 18:26:19 +0000
committerngie <ngie@FreeBSD.org>2017-03-27 18:26:19 +0000
commitc892be0f144d569d439793d29e35e91f1098aa2c (patch)
tree26d93d387832f0239c3418f4429c4ded79e9d643 /contrib/bsnmp/lib
parent5adb62ab7602a742c3150c42d513dbc7d05b3311 (diff)
downloadFreeBSD-src-c892be0f144d569d439793d29e35e91f1098aa2c.zip
FreeBSD-src-c892be0f144d569d439793d29e35e91f1098aa2c.tar.gz
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(..).
Diffstat (limited to 'contrib/bsnmp/lib')
-rw-r--r--contrib/bsnmp/lib/snmpclient.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/contrib/bsnmp/lib/snmpclient.c b/contrib/bsnmp/lib/snmpclient.c
index 2dc9eb8..bb711ee 100644
--- a/contrib/bsnmp/lib/snmpclient.c
+++ b/contrib/bsnmp/lib/snmpclient.c
@@ -947,6 +947,8 @@ open_client_udp(const char *host, const char *port)
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 *port, const char *readcomm,
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;
OpenPOWER on IntegriCloud