Browse Source

Fix for garbage output in mutliline plugin output

Ethan Galstad 18 years ago
parent
commit
91670c9dbe
5 changed files with 27 additions and 22 deletions
  1. 5 0
      Changelog
  2. 3 2
      include/common.h
  3. 6 6
      include/dh.h
  4. 3 3
      src/check_nrpe.c
  5. 10 11
      src/nrpe.c

+ 5 - 0
Changelog

@@ -3,6 +3,11 @@ NRPE Changelog
 **************
 
 
+2.12 - ??/??/2008
+-----------------
+- Fix for unterminated multiline plugin (garbage) output (Krzysztof Oledzki)
+
+
 
 2.11 - 12/26/2007
 -----------------

+ 3 - 2
include/common.h

@@ -1,7 +1,7 @@
 /************************************************************************
  *
  * COMMON.H - NRPE Common Include File
- * Copyright (c) 1999-2006 Ethan Galstad (nagios@nagios.org)
+ * Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
  * Last Modified: 12-26-2007
  *
  * License:
@@ -56,7 +56,8 @@
 #define QUERY_PACKET		1		/* id code for a packet containing a query */
 #define	RESPONSE_PACKET		2		/* id code for a packet containing a response */
 
-#define NRPE_PACKET_VERSION_2   2               /* packet version identifier */
+#define NRPE_PACKET_VERSION_3   3               /* packet version identifier */
+#define NRPE_PACKET_VERSION_2   2               
 #define NRPE_PACKET_VERSION_1	1		/* older packet version identifiers (no longer supported) */
 
 #define MAX_PACKETBUFFER_LENGTH	1024		/* max amount of data we'll send in one query/response */

+ 6 - 6
include/dh.h

@@ -4,12 +4,12 @@
 DH *get_dh512()
 	{
 	static unsigned char dh512_p[]={
-		0xB8,0xDD,0x6F,0x79,0x72,0xD2,0x5B,0xAA,0x5B,0xAA,0x86,0x18,
-		0x9C,0x0E,0xE1,0xD7,0x8E,0xB6,0x6C,0x19,0x47,0xE7,0xF0,0xDC,
-		0xCE,0xB0,0xFD,0x61,0x2E,0x34,0xCD,0x3E,0x62,0x3B,0x8A,0xA4,
-		0x0C,0x53,0x24,0xFE,0x03,0x1B,0x45,0x5B,0xBF,0x13,0x48,0x76,
-		0x07,0x59,0xDD,0x13,0x2E,0x87,0x11,0x0F,0x3E,0xAA,0xD7,0xF1,
-		0xAF,0x15,0x27,0x83,
+		0xDF,0x76,0x75,0x01,0x80,0x9E,0xB8,0x4E,0xF5,0x77,0x73,0x47,
+		0x3E,0xBE,0x46,0xFA,0x23,0xF6,0x03,0x35,0x56,0xBE,0x38,0x67,
+		0xF0,0x62,0xFE,0x9A,0x2F,0x9E,0x0D,0xF3,0x2D,0x91,0x64,0x6D,
+		0x1F,0x5B,0x40,0x09,0x7B,0x10,0x43,0xCE,0xF9,0x9E,0xE7,0x2F,
+		0xBE,0x7B,0x89,0x64,0x57,0xCA,0x2A,0x13,0x19,0x7F,0xB1,0xA4,
+		0xA0,0x6D,0x42,0x0B,
 		};
 	static unsigned char dh512_g[]={
 		0x02,

+ 3 - 3
src/check_nrpe.c

@@ -1,10 +1,10 @@
 /********************************************************************************************
  *
  * CHECK_NRPE.C - NRPE Plugin For Nagios
- * Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
+ * Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 12-26-2007
+ * Last Modified: 01-24-2008
  *
  * Command line: CHECK_NRPE -H <host_address> [-p port] [-c command] [-to to_sec]
  *
@@ -72,7 +72,7 @@ int main(int argc, char **argv){
 			printf("Incorrect command line arguments supplied\n");
                 printf("\n");
 		printf("NRPE Plugin for Nagios\n");
-		printf("Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)\n");
+		printf("Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)\n");
 		printf("Version: %s\n",PROGRAM_VERSION);
 		printf("Last Modified: %s\n",MODIFICATION_DATE);
 		printf("License: GPL v2 with exemptions (-l for more info)\n");

+ 10 - 11
src/nrpe.c

@@ -1,10 +1,10 @@
 /*******************************************************************************
  *
  * NRPE.C - Nagios Remote Plugin Executor
- * Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)
+ * Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)
  * License: GPL
  *
- * Last Modified: 12-26-2007
+ * Last Modified: 01-24-2008
  *
  * Command line: nrpe -c <config_file> [--inetd | --daemon]
  *
@@ -106,7 +106,7 @@ int main(int argc, char **argv){
 
 		printf("\n");
 		printf("NRPE - Nagios Remote Plugin Executor\n");
-		printf("Copyright (c) 1999-2007 Ethan Galstad (nagios@nagios.org)\n");
+		printf("Copyright (c) 1999-2008 Ethan Galstad (nagios@nagios.org)\n");
 		printf("Version: %s\n",PROGRAM_VERSION);
 		printf("Last Modified: %s\n",MODIFICATION_DATE);
 		printf("License: GPL v2 with exemptions (-l for more info)\n");
@@ -1322,7 +1322,6 @@ int my_system(char *command,int timeout,int *early_timeout,char *output,int outp
 	int result;
 	extern int errno;
 	char buffer[MAX_INPUT_BUFFER];
-	char temp_buffer[MAX_INPUT_BUFFER];
 	int fd[2];
 	FILE *fp;
 	int bytes_read=0;
@@ -1452,14 +1451,15 @@ int my_system(char *command,int timeout,int *early_timeout,char *output,int outp
 
 		/* try and read the results from the command output (retry if we encountered a signal) */
 		if(output!=NULL){
-			strcpy(output,"");
 			do{
-				bytes_read=read(fd[0],output,output_length-1);
-		                }while(bytes_read==-1 && errno==EINTR);
-		        }
+				bytes_read=read(fd[0], output, output_length-1);
+			}while (bytes_read==-1 && errno==EINTR);
 
-		if(bytes_read==-1 && output!=NULL)
-			strcpy(output,"");
+			if(bytes_read==-1)
+				*output='\0';
+			else
+				output[bytes_read]='\0';
+			}
 
 		/* if there was a critical return code and no output AND the command time exceeded the timeout thresholds, assume a timeout */
 		if(result==STATE_CRITICAL && bytes_read==-1 && (end_time-start_time)>=timeout){
@@ -1669,7 +1669,6 @@ int check_privileges(void){
 void sighandler(int sig){
 	static char *sigs[]={"EXIT","HUP","INT","QUIT","ILL","TRAP","ABRT","BUS","FPE","KILL","USR1","SEGV","USR2","PIPE","ALRM","TERM","STKFLT","CHLD","CONT","STOP","TSTP","TTIN","TTOU","URG","XCPU","XFSZ","VTALRM","PROF","WINCH","IO","PWR","UNUSED","ZERR","DEBUG",(char *)NULL};
 	int i;
-	char temp_buffer[MAX_INPUT_BUFFER];
 
 	if(sig<0)
 		sig=-sig;