[icinga-checkins] icinga.org: icinga-core/rbartels/cgi-current: fixed long plugin output of status.cgi for first long rewrite

git at icinga.org git at icinga.org
Tue Apr 5 17:02:46 CEST 2011


Module: icinga-core
Branch: rbartels/cgi-current
Commit: 5bc8cb248e65e10337afbee1f47a455c820a52a6
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=5bc8cb248e65e10337afbee1f47a455c820a52a6

Author: Ricardo Bartels <ricardo at bitchbrothers.com>
Date:   Tue Apr  5 17:01:59 2011 +0200

fixed long plugin output of status.cgi for first long rewrite

---

 cgi/status.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/cgi/status.c b/cgi/status.c
index 885cd8a..5b619b1 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -4600,11 +4600,11 @@ int add_status_data(int status_type, hoststatus *host_status, servicestatus *ser
 	char *status_string=NULL;
 	char *host_name=NULL;
 	char *svc_description=NULL;
-	char last_check[MAX_DATETIME_LENGTH];
-	char state_duration[48];
 	char *plugin_output_short=NULL;
 	char *plugin_output_long=NULL;
-	char plugin_output[MAX_INPUT_BUFFER];
+	char *plugin_output=NULL;
+	char last_check[MAX_DATETIME_LENGTH];
+	char state_duration[48];
 	char attempts[MAX_INPUT_BUFFER];
 	time_t ts_state_duration=0L;
 	time_t ts_last_check=0L;
@@ -4615,6 +4615,7 @@ int add_status_data(int status_type, hoststatus *host_status, servicestatus *ser
 	int seconds;
 	int duration_error=FALSE;
 	int status=OK;
+	int dummy=0;
 	int current_attempt=0;
 	int is_flapping=FALSE;
 	int problem_has_been_acknowledged=FALSE;
@@ -4727,21 +4728,20 @@ int add_status_data(int status_type, hoststatus *host_status, servicestatus *ser
 	/* plugin ouput */
 	if (status_show_long_plugin_output!=FALSE && plugin_output_long!=NULL) {
 		if(content_type==CSV_CONTENT)
-			snprintf(plugin_output,sizeof(plugin_output)-1,"%s %s",plugin_output_short,escape_newlines(plugin_output_long));
+			dummy=asprintf(&plugin_output,"%s %s",plugin_output_short,escape_newlines(plugin_output_long));
 		else
-			snprintf(plugin_output,sizeof(plugin_output)-1,"%s<BR>%s",html_encode(plugin_output_short,TRUE),html_encode(plugin_output_long,TRUE));
+			dummy=asprintf(&plugin_output,"%s<BR>%s",html_encode(plugin_output_short,TRUE),html_encode(plugin_output_long,TRUE));
 	} else if (plugin_output_short!=NULL) {
 		if(content_type==CSV_CONTENT)
-			snprintf(plugin_output,sizeof(plugin_output)-1,"%s",plugin_output_short);
+			dummy=asprintf(&plugin_output,"%s",plugin_output_short);
 		else
-			snprintf(plugin_output,sizeof(plugin_output)-1,"%s ",html_encode(plugin_output_short,TRUE));
+			dummy=asprintf(&plugin_output,"%s ",html_encode(plugin_output_short,TRUE));
 	} else {
 		if(content_type==CSV_CONTENT)
-			snprintf(plugin_output,sizeof(plugin_output)-1,"-");
+			dummy=asprintf(&plugin_output,"-");
 		else
-			snprintf(plugin_output,sizeof(plugin_output)-1," ");
+			dummy=asprintf(&plugin_output," ");
 	}
-	plugin_output[sizeof(plugin_output)-1]='\x0';
 
 	/* allocating new memory */
 	new_statusdata=(statusdata *)malloc(sizeof(statusdata));





More information about the icinga-checkins mailing list