summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/netutils.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/plugins/netutils.c b/plugins/netutils.c
index c99983f..aee53d3 100644
--- a/plugins/netutils.c
+++ b/plugins/netutils.c
@@ -213,7 +213,7 @@ static int
213my_connect (const char *host_name, int port, int *sd, int proto) 213my_connect (const char *host_name, int port, int *sd, int proto)
214{ 214{
215 struct addrinfo hints; 215 struct addrinfo hints;
216 struct addrinfo *res; 216 struct addrinfo *res, *res0;
217 char port_str[6]; 217 char port_str[6];
218 int result; 218 int result;
219 219
@@ -223,13 +223,14 @@ my_connect (const char *host_name, int port, int *sd, int proto)
223 hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM; 223 hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
224 224
225 snprintf (port_str, sizeof (port_str), "%d", port); 225 snprintf (port_str, sizeof (port_str), "%d", port);
226 result = getaddrinfo (host_name, port_str, &hints, &res); 226 result = getaddrinfo (host_name, port_str, &hints, &res0);
227 227
228 if (result != 0) { 228 if (result != 0) {
229 printf ("%s\n", gai_strerror (result)); 229 printf ("%s\n", gai_strerror (result));
230 return STATE_UNKNOWN; 230 return STATE_UNKNOWN;
231 } 231 }
232 else { 232 else {
233 res = res0;
233 while (res) { 234 while (res) {
234 /* attempt to create a socket */ 235 /* attempt to create a socket */
235 *sd = socket (res->ai_family, (proto == IPPROTO_UDP) ? 236 *sd = socket (res->ai_family, (proto == IPPROTO_UDP) ?
@@ -260,7 +261,7 @@ my_connect (const char *host_name, int port, int *sd, int proto)
260 close (*sd); 261 close (*sd);
261 res = res->ai_next; 262 res = res->ai_next;
262 } 263 }
263 freeaddrinfo (res); 264 freeaddrinfo (res0);
264 } 265 }
265 266
266 if (result == 0) 267 if (result == 0)