[Nagiosplug-devel] check_tcp cores on Solaris when connection refused - have a fix
Lynne Lawrence
llawrence at osc.uscg.mil
Thu Sep 30 20:08:07 CEST 2004
Folks,
Nice project - thanks for all your work!
I write because I have found a problem with netutils.c which causes
check_tcp to core on my Solaris 8 system. I am "tcp-pinging" the jabber
port on some servers and found that running the following against a host
where the jabber service is down causes check_tcp to core:
myuser: LD_LIBRARY_PATH=/usr/local/ssl/lib old/check_tcp -p 5222 -H
10.149.71.141
Segmentation Fault(coredump)
myuser: pstack core
core 'core' of 28148: old/check_tcp -p 5222 -H 10.149.71.141
ff374b44 freeaddrinfo (0, 0, 10, 1, 21b84, 144f4) + 8
00014510 my_connect (0, 2e000, 2e2e0, 6, 2151c, ffbefc30) + 100
00012d38 main (5, 2e000, ffbefcc4, 2e000, 2e000, 1c000) + 160
00012a64 _start (0, 0, 0, 0, 0, 0) + 5c
I have modified netutils.c so that it now returns correctly:
user: LD_LIBRARY_PATH=/usr/local/ssl/lib new/check_tcp -p 5222 -H
10.149.71.141
Connection refused
Here is the change I made to netutils.c (This change made to the
netutils.c I checked out of cvs today) I don't know that this is the
best solution, but it certainly works :-):
*** netutils.c.new Thu Sep 30 11:53:26 2004
--- netutils.c Thu Sep 30 14:05:02 2004
***************
*** 214,219 ****
--- 214,220 ----
{
struct addrinfo hints;
struct addrinfo *res;
+ struct addrinfo *orig_res;
char port_str[6];
int result;
***************
*** 230,235 ****
--- 231,237 ----
return STATE_UNKNOWN;
}
else {
+ orig_res = res;
while (res) {
/* attempt to create a socket */
*sd = socket (res->ai_family, (proto ==
IPPROTO_UDP) ?
***************
*** 237,243 ****
if (*sd < 0) {
printf ("Socket creation failed\n");
! freeaddrinfo (res);
return STATE_UNKNOWN;
}
--- 239,245 ----
if (*sd < 0) {
printf ("Socket creation failed\n");
! freeaddrinfo (orig_res);
return STATE_UNKNOWN;
}
***************
*** 260,266 ****
close (*sd);
res = res->ai_next;
}
! freeaddrinfo (res);
}
if (result == 0)
--- 262,268 ----
close (*sd);
res = res->ai_next;
}
! freeaddrinfo (orig_res);
}
if (result == 0)
I am not a member of this list, though I am on the users list, so please
respond directly if there is a need. - thanks again - Lynne
More information about the Devel
mailing list