[icinga-checkins] icinga.org: icinga-core/master: idoutils: fix ido2db needs to check for empty command arguments on Solaris ( Julian Wiesner) #1047

git at icinga.org git at icinga.org
Mon Jan 10 16:19:18 CET 2011


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

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed Jan  5 17:20:51 2011 +0100

idoutils: fix ido2db needs to check for empty command arguments on Solaris (Julian Wiesner) #1047

fixes #1047

---

 Changelog                        |    1 +
 THANKS                           |    1 +
 module/idoutils/src/dbhandlers.c |   31 +++++++++++++++++++++++++------
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/Changelog b/Changelog
index 166aa6c..665a1c7 100644
--- a/Changelog
+++ b/Changelog
@@ -69,6 +69,7 @@ FIXES
 * install: add hint to configure that libpq is not yet fully working #622
 
 * idoutils: fix unescape display name (Matthieu Kermagoret) #1027
+* idoutils: fix ido2db needs to check for empty command arguments on Solaris (Julian Wiesner) #1047
 
 1.2.1 - 25/10/2010
 
diff --git a/THANKS b/THANKS
index ce95a0f..1b8c200 100644
--- a/THANKS
+++ b/THANKS
@@ -315,6 +315,7 @@ in various ways.  If we missed your name, let us know.
 * Peter Westlake
 * Todd Wheeler
 * Florian Weimer
+* Julian Wiesner
 * Tim Wilde
 * Chris Witterholt
 * Evan Winter
diff --git a/module/idoutils/src/dbhandlers.c b/module/idoutils/src/dbhandlers.c
index 5c78380..e18c47e 100644
--- a/module/idoutils/src/dbhandlers.c
+++ b/module/idoutils/src/dbhandlers.c
@@ -5302,13 +5302,19 @@ int ido2db_handle_hostdefinition(ido2db_idi *idi) {
 	cmdptr = strtok(idi->buffered_input[IDO_DATA_HOSTCHECKCOMMAND], "!");
 	argptr = strtok(NULL, "\x0");
 	result = ido2db_get_object_id_with_insert(idi, IDO2DB_OBJECTTYPE_COMMAND, cmdptr, NULL, &check_command_id);
-	es[2] = ido2db_db_escape_string(idi, argptr);
+	if(argptr != NULL)
+		es[2] = ido2db_db_escape_string(idi, argptr);
+	else
+		es[2] = "\0";
 
 	/* get the event handler command */
 	cmdptr = strtok(idi->buffered_input[IDO_DATA_HOSTEVENTHANDLER], "!");
 	argptr = strtok(NULL, "\x0");
 	result = ido2db_get_object_id_with_insert(idi, IDO2DB_OBJECTTYPE_COMMAND, cmdptr, NULL, &eventhandler_command_id);
-	es[3] = ido2db_db_escape_string(idi, argptr);
+	if(argptr != NULL)
+		es[3] = ido2db_db_escape_string(idi, argptr);
+	else
+		es[3] = "\0";
 
 	es[4] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_NOTES]);
 	es[5] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_NOTESURL]);
@@ -5840,7 +5846,10 @@ int ido2db_handle_servicedefinition(ido2db_idi *idi) {
 
 	result = ido2db_get_object_id_with_insert(idi, IDO2DB_OBJECTTYPE_COMMAND, cmdptr, NULL, &check_command_id);
 
-	es[1] = ido2db_db_escape_string(idi, argptr);
+	if(argptr != NULL)
+		es[1] = ido2db_db_escape_string(idi, argptr);
+	else
+		es[1] = "\0";
 
 	/* get the event handler command */
 	cmdptr = strtok(idi->buffered_input[IDO_DATA_SERVICEEVENTHANDLER], "!");
@@ -5848,7 +5857,11 @@ int ido2db_handle_servicedefinition(ido2db_idi *idi) {
 
 	result = ido2db_get_object_id_with_insert(idi, IDO2DB_OBJECTTYPE_COMMAND, cmdptr, NULL, &eventhandler_command_id);
 
-	es[2] = ido2db_db_escape_string(idi, argptr);
+	if(argptr != NULL)
+		es[2] = ido2db_db_escape_string(idi, argptr);
+	else
+		es[2] = "\0";
+
 	es[3] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_NOTES]);
 	es[4] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_NOTESURL]);
 	es[5] = ido2db_db_escape_string(idi, idi->buffered_input[IDO_DATA_ACTIONURL]);
@@ -7249,7 +7262,10 @@ int ido2db_handle_contactdefinition(ido2db_idi *idi) {
 		/* find the command */
 		result = ido2db_get_object_id_with_insert(idi, IDO2DB_OBJECTTYPE_COMMAND, cmdptr, NULL, &command_id);
 
-		es[0] = ido2db_db_escape_string(idi, argptr);
+		if(argptr != NULL)
+			es[0] = ido2db_db_escape_string(idi, argptr);
+		else
+			es[0] = "\0";
 
 		/* save entry to db */
 	        data[0] = (void *) &idi->dbinfo.instance_id;
@@ -7294,7 +7310,10 @@ int ido2db_handle_contactdefinition(ido2db_idi *idi) {
 		/* find the command */
 		result = ido2db_get_object_id_with_insert(idi, IDO2DB_OBJECTTYPE_COMMAND, cmdptr, NULL, &command_id);
 
-		es[0] = ido2db_db_escape_string(idi, argptr);
+		if(argptr != NULL)
+			es[0] = ido2db_db_escape_string(idi, argptr);
+		else
+			es[0] = "\0";
 
 		/* save entry to db */
 





More information about the icinga-checkins mailing list