Uploaded image for project: 'ZABBIX BUGS AND ISSUES'
  1. ZABBIX BUGS AND ISSUES
  2. ZBX-10599

Uninitialized variable in runtime commands reported by Coverity

XMLWordPrintable

      Variable found can stay uninitialized if loop continues several times and then breaks (CID 118959):

      static void	zbx_signal_process_by_pid(int pid, int flags)
      {
      	...
      	int		i, found;
      	...
      	for (i = 0; i < threads_num; i++)
      	{
      		if (0 != pid && threads[i] != ZBX_RTC_GET_DATA(flags))
      			continue;
      
      		found = 1;
      		...
      	}
      
      	if (0 != ZBX_RTC_GET_DATA(flags) && 0 == found)	/* <--- here */
      		...
      }
      

      Can be confirmed using Valgrind:

      $ valgrind --tool=memcheck --leak-check=full --log-file=/tmp/valgrind.log zabbix_agentd -c /path/to/config/agentd.conf
      $ zabbix_agentd -c /path/to/config/agentd.conf -R log_level_increase=1
      zabbix_agentd [18743]: command sent successfully
      

      Valgrind reports:

      ==18699== Conditional jump or move depends on uninitialised value(s)
      ==18699==    at 0x4359B7: zbx_signal_process_by_pid (in /path/to/zabbix_agentd)
      ==18699==    by 0x435BEE: user1_signal_handler (in /path/to/zabbix_agentd)
      ==18699==    by 0x528CD3F: ??? (in /lib/x86_64-linux-gnu/libc-2.19.so)
      ==18699==    by 0x5316AB1: wait (wait.c:30)
      ==18699==    by 0x41826B: MAIN_ZABBIX_ENTRY (in /path/to/zabbix_agentd)
      ==18699==    by 0x43605E: daemon_start (in /path/to/zabbix_agentd)
      ==18699==    by 0x41867A: main (in /path/to/zabbix_agentd)
      

            Unassigned Unassigned
            glebs.ivanovskis Glebs Ivanovskis (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: