[dev.icinga.com #2601] Segmentation fault in ido2db dbqueries.c #967

Closed
icinga-migration opened this Issue May 11, 2012 · 7 comments

Projects

None yet

1 participant

@icinga-migration
Member

This issue has been migrated from Redmine: https://dev.icinga.com/issues/2601

Created by jmosshammer on 2012-05-11 11:10:10 +00:00

Assignee: jmosshammer
Status: Resolved (closed on 2012-05-14 15:13:06 +00:00)
Target Version: 1.7
Last Update: 2014-12-08 14:35:59 +00:00 (in Redmine)

Icinga Version: 1.10.0
OS Version: any

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*) data[4]) > IDO2DB_MYSQL_MAX_TEXT_LEN ) {
3573 ((char*) data[5])[IDO2DB_MYSQL_MAX_TEXT_LEN]=0;

Here, the length of data[4] is checked, but the char in data[5] is being truncated. I changed it to:

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

Which works fine

Changesets

2012-05-13 17:54:42 +00:00 by mfriedrich 3aa3c09

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

refs #2601

Relations:

@icinga-migration
Member

Updated by mfriedrich on 2012-05-11 14:03:56 +00:00

why was that limited anyway?

@icinga-migration
Member

Updated by mfriedrich on 2012-05-13 17:39:15 +00:00

  • Category set to 57
  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
  • Target Version set to 1.7

ok, this was introduced with this commit in #2342

commit f04c704b0a708d60223ea9e2aabf41865e80ce7d
Author: Thomas Dressler 
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");
+               }
@icinga-migration
Member

Updated by mfriedrich on 2012-05-13 17:57:51 +00:00

  • Assigned to changed from mfriedrich to jmosshammer

can you test the fix in 'next' please?

https://git.icinga.org/?p=icinga-core.git;a=shortlog;h=refs/heads/next
https://git.icinga.org/?p=icinga-core.git;a=commit;h=3aa3c09c1f80a475278020fda5db7b19cb62637f

@icinga-migration
Member

Updated by mfriedrich on 2012-05-14 15:13:06 +00:00

  • 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.

@icinga-migration
Member

Updated by Tommi on 2012-05-14 18:05:00 +00:00

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

@icinga-migration
Member

Updated by mfriedrich on 2012-05-14 18:12:54 +00:00

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

@icinga-migration
Member

Updated by mfriedrich on 2014-12-08 14:35:59 +00:00

  • Project changed from 18 to Core, Classic UI, IDOUtils
  • Category changed from 57 to IDOUtils
  • Icinga Version set to 1
  • OS Version set to any
@icinga-migration icinga-migration added this to the 1.7 milestone Jan 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment