#! /bin/sh /usr/share/dpatch/dpatch-run
## 95_fix-multiurl-action-status-icon-macro-processing-fix.dpatch.dpatch by Michael Friedrich <michael.friedrich@univie.ac.at>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: fix multiurl action/status icon+macro processing; fix invalid pointer in extinfo.cgi
@DPATCH@
diff --git a/Changelog b/Changelog
index ebdc6db..8b4c30b 100644
--- a/Changelog
+++ b/Changelog
@@ -13,6 +13,8 @@ FIXES
* core: fix wrong is_volatile conditions causing wrong service alerts in the logs
* classic ui: fix image urls ins stylesheets
+* classic ui: fix invalid pointer in extinfo.cgi type=7
+fix macro processing (Jochen Bern)
* install: fix api not installed using make install-unstripped
* install: enable debuginfo in spec file
diff --git a/cgi/extinfo.c b/cgi/extinfo.c
index 55fc382..63cf8dd 100644
--- a/cgi/extinfo.c
+++ b/cgi/extinfo.c
@@ -2975,8 +2975,6 @@ void show_scheduling_queue(void){
printf("&service=%s%s'><img src='%s%s' border=0 ALT='Re-schedule This Service Check' TITLE='Re-schedule This Service Check'></a>\n",url_encode(temp_svcstatus->description),(temp_svcstatus->checks_enabled==TRUE)?"&force_check":"",url_images_path,DELAY_ICON);
printf("</TD>\n");
- free(temp_host);
- free(temp_service);
}
/* get the host status */
@@ -3027,7 +3025,6 @@ void show_scheduling_queue(void){
printf("'><img src='%s%s' border=0 ALT='Re-schedule This Host Check' TITLE='Re-schedule This Host Check'></a>\n",url_images_path,DELAY_ICON);
printf("</TD>\n");
- free(temp_host);
}
printf("</TR>\n");
diff --git a/cgi/status.c b/cgi/status.c
index 3e70fa7..ee91a19 100644
--- a/cgi/status.c
+++ b/cgi/status.c
@@ -1731,7 +1731,7 @@ void show_service_detail(void){
printf("<A HREF='");
printf("%s",processed_string);
printf("' TARGET='%s'>",(notes_url_target==NULL)?"_blank":notes_url_target);
- printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,NOTES_ICON,MU_iconstr,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Service Notes","View Extra Service Notes");
+ printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,MU_iconstr,NOTES_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"View Extra Service Notes","View Extra Service Notes");
printf("</A>");
printf("</TD>\n");
END_MULTIURL_LOOP
@@ -1744,7 +1744,7 @@ void show_service_detail(void){
printf("<A HREF='");
printf("%s",processed_string);
printf("' TARGET='%s'>",(action_url_target==NULL)?"_blank":action_url_target);
- printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,ACTION_ICON,MU_iconstr,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Service Actions","Perform Extra Service Actions");
+ printf("<IMG SRC='%s%s%s' BORDER=0 WIDTH=%d HEIGHT=%d ALT='%s' TITLE='%s'>",url_images_path,MU_iconstr,ACTION_ICON,STATUS_ICON_WIDTH,STATUS_ICON_HEIGHT,"Perform Extra Service Actions","Perform Extra Service Actions");
printf("</A>");
printf("</TD>\n");
END_MULTIURL_LOOP
diff --git a/common/macros.c b/common/macros.c
index 149b338..01e54fe 100644
--- a/common/macros.c
+++ b/common/macros.c
@@ -77,6 +77,7 @@ contactgroup *macro_contactgroup_ptr=NULL;
/* replace macros in notification commands with their values */
int process_macros(char *input_buffer, char **output_buffer, int options){
char *temp_buffer=NULL;
+ char *save_buffer=NULL;
char *buf_ptr=NULL;
char *delim_ptr=NULL;
int in_macro=FALSE;
@@ -107,7 +108,9 @@ int process_macros(char *input_buffer, char **output_buffer, int options){
log_debug_info(DEBUGL_MACROS,1,"**** BEGIN MACRO PROCESSING ***********\n");
log_debug_info(DEBUGL_MACROS,1,"Processing: '%s'\n",input_buffer);
- buf_ptr=input_buffer;
+ /* save original input_buffer ptr for later free'ing */
+ save_buffer=buf_ptr=(input_buffer?strdup(input_buffer):NULL);
+
while(buf_ptr){
/* save pointer to this working part of buffer */
@@ -240,6 +243,9 @@ int process_macros(char *input_buffer, char **output_buffer, int options){
log_debug_info(DEBUGL_MACROS,1," Done. Final output: '%s'\n",*output_buffer);
log_debug_info(DEBUGL_MACROS,1,"**** END MACRO PROCESSING *************\n");
+ if (save_buffer)
+ free(save_buffer);
+
return OK;
}
--
1.7.1