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

git at icinga.org git at icinga.org
Thu Jan 13 15:57:30 CET 2011


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

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 52f8e1a..494ddb9 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ FIXES
 * install: add log2ido for adding archived logs onto socket/rdbms #926
 * install: add hint to configure that libpq is not yet fully working #622
 
+* 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 a38552d..5bed90d 100644
--- a/THANKS
+++ b/THANKS
@@ -313,6 +313,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