Page 1 of 1

[Nagios-devel] Patches for Nagios current

Posted: Thu Sep 30, 2004 4:32 am
by Guest
This is a multi-part message in MIME format.
--------------050403060309070408070909
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

One of the patches fixes a SIGSEGV caused by one of two strdup(NULL)
calls in xdata/xpddefault.c, where two variables (for perfdatafiles)
aren't checked for NULL-ness before being strdup()'ed into the macro_x
array. The patch properly replaces those macros with empty strings if
the variables are NULL.

The second patch fixes an issue with commands not being sent because the
command line might get chopped up.
From what I read in the source, any line in any file can be any length
nowadays (65536?), but notification commands are still being cut off at
1024 chars. That's sort of silly, since it doesn't allow for all the
macros available to fit in the notification command. This patch raises
the bar to 4096, by use of MAX_COMMAND_BUFFER in include/common.h.
It might be prudent to rename that to MAX_NOTIFICATION_COMMAND_BUFFER
and raise it further, but the patch at least points out the errors, and
it's now big enough to contain all the macros in the form of
MACRONAME=MACROVALUE and still leave about 1KiB for trivia.

Cheers

--
Andreas Ericsson [email protected]
OP5 AB www.op5.se
Lead Developer

--------------050403060309070408070909
Content-Type: text/plain;
name="nagios-cvs-strdup-with-NULL.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-cvs-strdup-with-NULL.diff"

diff -ur nagios.orig/xdata/xpddefault.c nagios-cvs/xdata/xpddefault.c
--- nagios.orig/xdata/xpddefault.c Sun Sep 12 15:37:12 2004
+++ nagios-cvs/xdata/xpddefault.c Thu Sep 30 13:31:12 2004
@@ -181,16 +181,24 @@
/* save the host perf data file macro */
if(macro_x[MACRO_HOSTPERFDATAFILE]!=NULL)
free(macro_x[MACRO_HOSTPERFDATAFILE]);
- macro_x[MACRO_HOSTPERFDATAFILE]=(char *)strdup(xpddefault_host_perfdata_file);
- if(macro_x[MACRO_HOSTPERFDATAFILE]!=NULL)
+ if(xpddefault_host_perfdata_file!=NULL){
+ macro_x[MACRO_HOSTPERFDATAFILE]=(char *)strdup(xpddefault_host_perfdata_file);
strip(macro_x[MACRO_HOSTPERFDATAFILE]);
+ }
+ else{
+ macro_x[MACRO_HOSTPERFDATAFILE]=(char *)"";
+ }

/* save the service perf data file macro */
if(macro_x[MACRO_SERVICEPERFDATAFILE]!=NULL)
free(macro_x[MACRO_SERVICEPERFDATAFILE]);
- macro_x[MACRO_SERVICEPERFDATAFILE]=(char *)strdup(xpddefault_service_perfdata_file);
- if(macro_x[MACRO_SERVICEPERFDATAFILE]!=NULL)
+ if(xpddefault_service_perfdata_file!=NULL){
+ macro_x[MACRO_SERVICEPERFDATAFILE]=(char *)strdup(xpddefault_service_perfdata_file);
strip(macro_x[MACRO_SERVICEPERFDATAFILE]);
+ }
+ else{
+ macro_x[MACRO_SERVICEPERFDATAFILE]=(char *)"";
+ }

return OK;
}

--------------050403060309070408070909
Content-Type: text/plain;
name="nagios-cvs-max_notification_cmd_len.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nagios-cvs-max_notification_cmd_len.diff"

diff -urN nagios.orig/base/notifications.c nagios-cvs/base/notifications.c
--- nagios.orig/base/notifications.c Sun Aug 15 11:13:59 2004
+++ nagios-cvs/base/notifications.c Thu Sep 30 13:37:16 2004
@@ -579,9 +579,9 @@
commandsmember *temp_commandsmember;
char command_name[MAX_INPUT_BUFFER];
char *command_name_ptr=NULL;
- char raw_command[MAX_INPUT_BUFFER];
- char processed_command[MAX_INPUT_BUFFER];
- char temp_buffer[MAX_INPUT_BUFFER];
+ char raw_command[MAX_COMMAND_BUFFER];
+ char processed_command[MAX_COMMAND_BUFFER];
+ char temp_buffer[MAX_COMMAND_BUFFER];
int early_timeout=FALSE;
double exectime;
int macro_options=STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS;
@@ -1260,9 +1260,9 @@
commandsmember *temp_commandsmember;
char command_name[MAX_INPUT_BUFFER];
char *command_name_ptr;
- char temp_buffer[MAX_INPUT_BUFFER];
- char raw_command[MAX_INPUT_BUFFER];
- char processed_command[MAX_INPUT_BUFFER];
+ char temp_buffer[MAX_COMMAND_BUFFER];
+ char raw_command[MAX_COMMAND_BUFFER];
+ char processed_command[MAX_COMMAND_BUFFER];
int early_timeout=FALSE;
double exectime;
int macro_options=STRIP_ILLEGAL_MA

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]