[Nagiosplug-devel] [ nagiosplug-Bugs-2991170 ] check_nt segfaults on unexpected server response

SourceForge.net noreply at sourceforge.net
Fri Apr 23 02:48:11 CEST 2010


Bugs item #2991170, was opened at 2010-04-23 10:48
Message generated for change (Tracker Item Submitted) made by 
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2991170&group_id=29880

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General plugin execution
Group: v1.4.14
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Thiago Figueiro ()
Assigned to: Nobody/Anonymous (nobody)
Summary: check_nt segfaults on unexpected server response

Initial Comment:
./check_nt -V
check_nt v1.4.14 (nagios-plugins 1.4.14)

(gdb) r
Starting program: /home/thiago/tmp/nagios-plugins-1.4.14/plugins/check_nt -p 1248 -H my_hostname -v SERVICESTATE -l MSSQLSERVER
[Thread debugging using libthread_db enabled]

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff729c441 in strlen () from /lib/libc.so.6
(gdb) bt
#0  0x00007ffff729c441 in strlen () from /lib/libc.so.6
#1  0x00007ffff729c196 in strdup () from /lib/libc.so.6
#2  0x0000000000402de8 in main (argc=<value optimized out>, argv=0x7fffffffe628) at check_nt.c:265

265:                         output_message = strdup (temp_string);


Patch:
--- check_nt.c	2009-05-08 07:08:25.000000000 +1000
+++ /tmp/check_nt.c	2010-04-23 10:38:58.000000000 +1000
@@ -260,9 +260,15 @@
 			asprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
 							 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
 			fetch_data (server_address, server_port, send_buffer);
+			if (strstr(recv_buffer, "&")) {
 			return_code=atoi(strtok(recv_buffer,"&"));
 			temp_string=strtok(NULL,"&");
 			output_message = strdup (temp_string);
+			} else {
+				asprintf(&temp_string,"Remote server error:[%s]", recv_buffer);
+				output_message = temp_string;
+				return_code=STATE_UNKNOWN;
+			}
 		}
 		break;


New output:
$ ./check_nt -p 1248 -H ausyd-gcdb01 -v SERVICESTATE -l MSSQLSERVER
Remote server error:[ERRRO: No command specified.
]



----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=397597&aid=2991170&group_id=29880




More information about the Devel mailing list