[icinga-checkins] icinga.org: icinga-core/master: if getenv returns NULL, a strcmp must not happen ...

git at icinga.org git at icinga.org
Wed Mar 16 17:54:19 CET 2011


Module: icinga-core
Branch: master
Commit: af9ef8f467a10226462372ce19375255bde01934
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=af9ef8f467a10226462372ce19375255bde01934

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Mar 16 17:53:19 2011 +0100

if getenv returns NULL, a strcmp must not happen ...

---

 cgi/cgiutils.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/cgi/cgiutils.c b/cgi/cgiutils.c
index 68e7945..6bf2c32 100644
--- a/cgi/cgiutils.c
+++ b/cgi/cgiutils.c
@@ -2503,12 +2503,15 @@ char *get_export_csv_link(char *cgi) {
 	static char ret[MAX_INPUT_BUFFER]="";
 
 	/* just do stuff if some options are requested */
-	if(strcmp(getenv("QUERY_STRING"),"")) {
-		snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s",getenv("QUERY_STRING"));
-		temp_buffer[sizeof(temp_buffer)-1]='\x0';
-		strip_html_brackets(temp_buffer);
-		snprintf(ret,sizeof(ret)-1,"%s?%s&csvoutput",cgi,temp_buffer);
-		ret[sizeof(ret)-1]='\x0';
+	if(getenv("QUERY_STRING")!=NULL){
+		if(strcmp(getenv("QUERY_STRING"),"")) {
+			snprintf(temp_buffer,sizeof(temp_buffer)-1,"%s",getenv("QUERY_STRING"));
+			temp_buffer[sizeof(temp_buffer)-1]='\x0';
+			strip_html_brackets(temp_buffer);
+			snprintf(ret,sizeof(ret)-1,"%s?%s&csvoutput",cgi,temp_buffer);
+			ret[sizeof(ret)-1]='\x0';
+		} else
+			snprintf(ret,sizeof(ret)-1,"%s?csvoutput",cgi);
 	} else
 		snprintf(ret,sizeof(ret)-1,"%s?csvoutput",cgi);
 





More information about the icinga-checkins mailing list