Package: nagios-plugins
Version: 1.4.3.0cvs.20060707-3
Tags: patch

Specifying more than one -e (expect reponse string) argument to
check_tcp leads to SEGV.


Simplified examples:

"check_tcp -H server -p port -s test -e foo"        works

"check_tcp -H server -p port -s test -e foo -e bar" segfaults.

Real-life example (server name hidden):

roessner(gorkon)~$ /usr/lib/nagios/plugins/check_tcp -H <hidden>  -p 143 -s '0 
foo' -e test -e test2 -v
Using service TCP
Port: 143
flags: 0x2
Send string: 0 foo
server_expect_count: 2
        0: (null)
        1: test2
received 64 bytes from host
#-raw-recv-------#
* OK magellan Cyrus IMAP4 v2.2.13-Debian-2.2.13-3 server ready

#-raw-recv-------#
looking for [(null)] anywhere in [* OK magellan Cyrus IMAP4 
v2.2.13-Debian-2.2.13-3 server ready]
Segmentation fault
roessner(gorkon)~$


You will notice the "0: (null)" entry in the list of expected strings.
This is due to bad argument parsing in check_tcp.c . The first argument
string is explicitly overwritten with a NULL, which is a Bad Thing and
serves no useful purpose.


Patch to resolve this:

*** nagios-plugins-1.4.3.0cvs.20060707/plugins/check_tcp.c.orig 2006-09-28 
18:56:19.000000000 +0200
--- nagios-plugins-1.4.3.0cvs.20060707/plugins/check_tcp.c      2006-09-28 
19:05:11.000000000 +0200
***************
*** 500,506 ****
                                asprintf(&server_send, "%s", optarg);
                        break;
                case 'e': /* expect string (may be repeated) */
-                       EXPECT = NULL;
                        flags &= ~FLAG_EXACT_MATCH;
                        if (server_expect_count == 0)
                                server_expect = malloc (sizeof (char *) * 
(++server_expect_count));
--- 500,505 ----


This bug was reported to upstream already as part of sourceforge project
nagiosplug / bug id 1475899. I have recently added some details there in
the hope that this will be fixed some time soon (that report dates from
april 24th).

Regards,
   Ralph Rößner


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to