Bug #2601

Segmentation fault in ido2db dbqueries.c

Added by jmosshammer almost 2 years ago. Updated almost 2 years ago.

Status:ResolvedStart date:05/11/2012
Priority:HighDue date:
Assignee:jmosshammer% Done:

100%

Category:Queries
Target version:Icinga 1.x - 1.7
Icinga Version: DB Type:
IDO Version: DB Version:

Description

this is probably related to #2342:
We still have problems with long outputs, causing pending states and active checks/notification disabled entries in the database.

As I didn't give real feedback to 2342, I debugged ido2db by myself and found the issue being a segmentation fault in the ido2db_query_insert_or_update_servicestatusdata_add function (dbqueries.c 3573):

3572 if (strlen((char *) data4) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
3573 ((char *) data5)[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;

Here, the length of data4 is checked, but the char in data5 is being truncated. I changed it to:

3572 if (strlen((char *) data5) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
3573 ((char *) data5)[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;

Which works fine


Related issues

Related to IDOUtils - Bug #2342: Long output data causes wrong data in database Resolved 02/22/2012

Associated revisions

Revision 3aa3c09c
Added by dnsmichi almost 2 years ago

fix wrong long_output and perfdata columns in servicestatusdata being truncated in mysql #2601

refs #2601

History

#1 Updated by dnsmichi almost 2 years ago

why was that limited anyway?

#2 Updated by dnsmichi almost 2 years ago

  • Category set to Queries
  • Status changed from New to Assigned
  • Assignee set to dnsmichi
  • Target version set to 1.7

ok, this was introduced with this commit in #2342

commit f04c704b0a708d60223ea9e2aabf41865e80ce7d
Author: Thomas Dressler <tdressler@tdressler.net>
Date:   Sat Mar 3 20:44:21 2012 +0100

    idoutils: truncate long_output and perfdata for mysql #2342
    refs #2342

-               dummy = asprintf(&query1, "INSERT INTO %s (instance_id, host_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, next$
+               /* truncate long_output #2342 */
+               if (strlen(*(char **) data[4]) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
+                       (*(char **) data[4])[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;
+                       ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_insert_or_update_hoststatusdata_add() Warning:long_output truncated\n");
+               }
+               if (strlen(*(char **) data[5]) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
+                       (*(char **) data[5])[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;
+                       ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_insert_or_update_hoststatusdata_add() Warning:perfdata truncated\n");
+               }

vs

-               dummy = asprintf(&query1, "INSERT INTO %s (instance_id, service_object_id, status_update_time, output, long_output, perfdata, current_state, has_been_checked, should_be_scheduled, current_check_attempt, max_check_attempts, last_check, n$
+               /* truncate long_output #2342 */
+               if (strlen(*(char **) data[4]) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
+                       (*(char **) data[5])[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;
+                       ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_insert_or_update_servicestatusdata_add() Warning:long_output truncated\n");
+               }
+               if (strlen(*(char **) data[4]) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
+                       (*(char **) data[4])[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;
+                       ido2db_log_debug_info(IDO2DB_DEBUGL_PROCESSINFO, 2, "ido2db_query_insert_or_update_servicestatusdata_add() Warning:perfdata truncated\n");
+               }

#4 Updated by dnsmichi almost 2 years ago

  • Status changed from Assigned to Resolved
  • % Done changed from 0 to 100

my tests run ok, and it should hit the release, otherwise a revert of the feature will be necessary in order to compete with QA.

re-open if more thoughts on that, my quickfix should do the trick for now.

#5 Updated by Tommi almost 2 years ago

copy and paste should be disabled, at least for me :-((((.
But please use the original ticket for such important issue. I wasn't notified and saw it now the first time

#6 Updated by dnsmichi almost 2 years ago

hmmm maybe you should change your settings to get all issues? at least i do get everything.

Also available in: Atom PDF