Ad Widget

Collapse

[1.3.9] Suspicious code in src/zabbix_server/functions.c:update_triggers()

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Farzad FARID
    Member
    • Apr 2007
    • 79

    #1

    [1.3.9] Suspicious code in src/zabbix_server/functions.c:update_triggers()

    Hi,

    When trying to understand the use of TRIGGER.VALUE (which I haven't found yet, because using {TRIGGER.VALUE} in my mail alert just prints a huge useless number..) I noticed a bit of code which may be slightly wrong.

    In functions.c: update_triggers() there is this piece of code:
    Code:
    	result = DBselect("select distinct t.triggerid,t.expression,t.status,t.dep_level,t.priority,t.value,t.description from triggers t,functions f,items i where i.status<>%d and i.itemid=f.itemid and t.status=%d and f.triggerid=t.triggerid and f.itemid=" ZBX_FS_UI64,
    		ITEM_STATUS_NOTSUPPORTED,
    		TRIGGER_STATUS_ENABLED,
    		itemid);
    
    	while((row=DBfetch(result)))
    	{
    		ZBX_STR2UINT64(trigger.triggerid,row[0]);
    		strscpy(trigger.expression,row[1]);
    		strscpy(trigger.description,row[6]);
    		trigger.status		= atoi(row[2]);
    		trigger.priority	= atoi(row[4]);
    		trigger.value		= atoi(row[5]);
    		trigger.url		= row[6];
    		trigger.comments	= row[7];
    The problems I see are:
    • There is no need to retrieve the value of t.status, as the SQL query imposes "t.status = TRIGGER_STATUS_ENABLED", so we already know this value
    • t.dep_level (a.k.a row[3]) isn't used anywhere, so it's not necessary to retrieve it.
    • row[6] is used twice, once as "description" and once as "url", one of the uses must be wrong...
    • there is no row[7] in the result (we only fetch 7 values in the SQL query), therefore the value put in "trigger.comments" must be meaningless.


    Regards
  • Alexei
    Founder, CEO
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2004
    • 5654

    #2
    Fixed, thanks for reporting this! Nore that the fix does not affect any functionality.
    Alexei Vladishev
    Creator of Zabbix, Product manager
    New York | Tokyo | Riga
    My Twitter

    Comment

    Working...