diff options
author | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-06-30 19:26:41 +0000 |
---|---|---|
committer | Martijn van Duren <martijn@cvs.openbsd.org> | 2020-06-30 19:26:41 +0000 |
commit | e742c75691891584626b33c3966c1c700801689c (patch) | |
tree | a119fdb67e10ded3abd5a0a7bdd6b0376ba43b3f /usr.bin | |
parent | da2bf588cc79557a2727bd2bb101c2db4862d39c (diff) |
Fix two minor issues in snmpc_parseagent.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/snmp/snmpc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/usr.bin/snmp/snmpc.c b/usr.bin/snmp/snmpc.c index 62fb1201a38..2c7f85172d2 100644 --- a/usr.bin/snmp/snmpc.c +++ b/usr.bin/snmp/snmpc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: snmpc.c,v 1.26 2020/05/31 21:01:59 martijn Exp $ */ +/* $OpenBSD: snmpc.c,v 1.27 2020/06/30 19:26:40 martijn Exp $ */ /* * Copyright (c) 2019 Martijn van Duren <martijn@openbsd.org> @@ -1237,7 +1237,7 @@ snmpc_parseagent(char *agent, char *defaultport) port = defaultport; error = getaddrinfo(hostname, port, &hints, &ai0); if (error) { - if (error != EAI_NODATA && port != defaultport) + if (error != EAI_NODATA || port == defaultport) errx(1, "%s", gai_strerror(error)); *--port = ':'; error = getaddrinfo(hostname, defaultport, &hints, @@ -1252,6 +1252,8 @@ snmpc_parseagent(char *agent, char *defaultport) connect(s, (struct sockaddr *)ai->ai_addr, ai->ai_addrlen) != -1) break; + close(s); + s = -1; } } else { s = socket(AF_UNIX, SOCK_STREAM, 0); |