[Nagiosplug-checkins] nagiosplug/plugins netutils.c,1.19,1.20
Stanley Hopcroft
stanleyhopcroft at users.sourceforge.net
Wed Dec 1 00:29:02 CET 2004
Update of /cvsroot/nagiosplug/nagiosplug/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20397
Modified Files:
netutils.c
Log Message:
1075725: patch to my_connect() to deal with SEGV if connect fails
Index: netutils.c
===================================================================
RCS file: /cvsroot/nagiosplug/nagiosplug/plugins/netutils.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- netutils.c 31 Mar 2004 22:48:11 -0000 1.19
+++ netutils.c 1 Dec 2004 08:28:36 -0000 1.20
@@ -213,7 +213,7 @@
my_connect (const char *host_name, int port, int *sd, int proto)
{
struct addrinfo hints;
- struct addrinfo *res;
+ struct addrinfo *res, *res0;
char port_str[6];
int result;
@@ -223,13 +223,14 @@
hints.ai_socktype = (proto == IPPROTO_UDP) ? SOCK_DGRAM : SOCK_STREAM;
snprintf (port_str, sizeof (port_str), "%d", port);
- result = getaddrinfo (host_name, port_str, &hints, &res);
+ result = getaddrinfo (host_name, port_str, &hints, &res0);
if (result != 0) {
printf ("%s\n", gai_strerror (result));
return STATE_UNKNOWN;
}
else {
+ res = res0;
while (res) {
/* attempt to create a socket */
*sd = socket (res->ai_family, (proto == IPPROTO_UDP) ?
@@ -260,7 +261,7 @@
close (*sd);
res = res->ai_next;
}
- freeaddrinfo (res);
+ freeaddrinfo (res0);
}
if (result == 0)
More information about the Commits
mailing list