Bug #261

wrong parameter used in ndo2db_db_query call in ndo2db_handle_acknowledgementdata

Added by brucep over 5 years ago. Updated over 5 years ago.

Status:ResolvedStart date:01/28/2010
Priority:HighDue date:
Assignee:dnsmichi% Done:

100%

Category:Event Broker
Target version:1.0.1
Icinga Version: OS Version:

Description

In dbhandlers.c, approx. line 3419, the call to ndo2db_db_query is wrong. Here is the relevant code:

if(asprintf(&buf1,"(instance_id, entry_time, entry_time_usec, acknowledgement_type, object_id, state, author_name, comment_data, is_sticky, persistent_comment, notify_contacts) VALUES (%lu, %s, %lu, %d, %lu, %d, '%s', '%s', %d, %d, %d)" 
,idi->dbinfo.instance_id
,ts[0]
,tstamp.tv_usec
,acknowledgement_type
,object_id
,state
,es[0]
,es[1]
,is_sticky
,persistent_comment
,notify_contacts
)==-1)
buf1=NULL;
if(asprintf(&buf,"INSERT INTO %s %s" 
,ndo2db_db_tablenames[NDO2DB_DBTABLE_ACKNOWLEDGEMENTS]
,buf1
)==-1)
buf=NULL;
free(buf1);
result = ndo2db_db_query(idi, buf1);

The call to ndo2db_db_query() should be passing buf as the second parameter, not buf1. There's also an extra call to free(buf1) slightly further down in the code.

Associated revisions

Revision 0b576e4d
Added by dnsmichi over 5 years ago

fix acknowledgments query

wrong buffer freed/set as query to db

fixes #261

History

#1 Updated by dnsmichi over 5 years ago

  • Assignee set to dnsmichi
  • Target version set to 1.0.1

thanks for debugging and pointing to the code. It's one of those things which have been rewritten due to useless unique constraint matching but did not happen while testing.

I will apply a quickfix right now :)

#2 Updated by dnsmichi over 5 years ago

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

Also available in: Atom PDF