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

Use of unitialized variable when linking template with host prototypes

XMLWordPrintable

    • Icon: Problem report Problem report
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • 5.0.0rc1, 5.0 (plan)
    • 5.0.0beta2
    • Server (S)
    • None
    • Sprint 63 (Apr 2020)
    • 0.125

      Flags variable is not initialized which can lead to macros being updated even if value hasn't changed.

      ==123279== Conditional jump or move depends on uninitialised value(s)
      ==123279==    at 0x643A68: DBhost_prototypes_save (host.c:3658)
      ==123279==    by 0x644764: DBcopy_template_host_prototypes (host.c:3906)
      ==123279==    by 0x648A8F: DBcopy_template_elements (host.c:5232)
      ==123279==    by 0x543307: op_template_add (operations.c:898)
      ==123279==    by 0x53947E: execute_operations (actions.c:1574)
      ==123279==    by 0x539B19: process_actions (actions.c:1806)
      ==123279==    by 0x53F58C: flush_events (events.c:2038)
      ==123279==    by 0x540F87: zbx_process_events (events.c:2755)
      ==123279==    by 0x63487E: DBregister_host_flush (db.c:1724)
      ==123279==    by 0x6339A0: DBregister_host (db.c:1410)
      ==123279==    by 0x465332: db_register_host (active.c:86)
      ==123279==    by 0x465C06: get_hostid_by_host (active.c:281)
      ==123279==  Uninitialised value was created by a heap allocation
      ==123279==    at 0x483980B: malloc (vg_replace_malloc.c:309)
      ==123279==    by 0x5D7865: zbx_malloc2 (misc.c:554)
      ==123279==    by 0x6434AA: DBhost_prototypes_macros_make (host.c:3537)
      ==123279==    by 0x644747: DBcopy_template_host_prototypes (host.c:3905)
      ==123279==    by 0x648A8F: DBcopy_template_elements (host.c:5232)
      ==123279==    by 0x543307: op_template_add (operations.c:898)
      ==123279==    by 0x53947E: execute_operations (actions.c:1574)
      ==123279==    by 0x539B19: process_actions (actions.c:1806)
      ==123279==    by 0x53F58C: flush_events (events.c:2038)
      ==123279==    by 0x540F87: zbx_process_events (events.c:2755)
      ==123279==    by 0x63487E: DBregister_host_flush (db.c:1724)
      ==123279==    by 0x6339A0: DBregister_host (db.c:1410)
      ==123279== 
      ==123279== Conditional jump or move depends on uninitialised value(s)
      ==123279==    at 0x64428B: DBhost_prototypes_save (host.c:3795)
      ==123279==    by 0x644764: DBcopy_template_host_prototypes (host.c:3906)
      ==123279==    by 0x648A8F: DBcopy_template_elements (host.c:5232)
      ==123279==    by 0x543307: op_template_add (operations.c:898)
      ==123279==    by 0x53947E: execute_operations (actions.c:1574)
      ==123279==    by 0x539B19: process_actions (actions.c:1806)
      ==123279==    by 0x53F58C: flush_events (events.c:2038)
      ==123279==    by 0x540F87: zbx_process_events (events.c:2755)
      ==123279==    by 0x63487E: DBregister_host_flush (db.c:1724)
      ==123279==    by 0x6339A0: DBregister_host (db.c:1410)
      ==123279==    by 0x465332: db_register_host (active.c:86)
      ==123279==    by 0x465C06: get_hostid_by_host (active.c:281)
      ==123279==  Uninitialised value was created by a heap allocation
      ==123279==    at 0x483980B: malloc (vg_replace_malloc.c:309)
      ==123279==    by 0x5D7865: zbx_malloc2 (misc.c:554)
      ==123279==    by 0x6434AA: DBhost_prototypes_macros_make (host.c:3537)
      ==123279==    by 0x644747: DBcopy_template_host_prototypes (host.c:3905)
      ==123279==    by 0x648A8F: DBcopy_template_elements (host.c:5232)
      ==123279==    by 0x543307: op_template_add (operations.c:898)
      ==123279==    by 0x53947E: execute_operations (actions.c:1574)
      ==123279==    by 0x539B19: process_actions (actions.c:1806)
      ==123279==    by 0x53F58C: flush_events (events.c:2038)
      ==123279==    by 0x540F87: zbx_process_events (events.c:2755)
      ==123279==    by 0x63487E: DBregister_host_flush (db.c:1724)
      ==123279==    by 0x6339A0: DBregister_host (db.c:1410)
      ==123279== 
      
      diff --git a/src/libs/zbxdbhigh/host.c b/src/libs/zbxdbhigh/host.c
      index 218dd761d4..60747385b4 100644
      --- a/src/libs/zbxdbhigh/host.c
      +++ b/src/libs/zbxdbhigh/host.c
      @@ -3539,6 +3539,7 @@ static void       DBhost_prototypes_macros_make(zbx_vector_ptr_t *host_prototypes, zbx
                      hostmacro->macro = zbx_strdup(NULL, row[1]);
                      hostmacro->value = zbx_strdup(NULL, row[2]);
                      hostmacro->description = zbx_strdup(NULL, row[3]);
      +               hostmacro->flags = 0;
                      ZBX_STR2UCHAR(hostmacro->type, row[4]);
       
                      zbx_vector_macros_append(&host_prototype->hostmacros, hostmacro);
      diff --git a/src/zabbix_server/lld/lld_host.c b/src/zabbix_server/lld/lld_host.c
      index caa35e2581..3948a3759a 100644
      --- a/src/zabbix_server/lld/lld_host.c
      +++ b/src/zabbix_server/lld/lld_host.c
      @@ -1773,7 +1773,7 @@ static void       lld_hostmacros_get(zbx_uint64_t parent_hostid, zbx_vector_ptr_t *mas
                      hostmacro->value = zbx_strdup(NULL, masterhostmacro->value);
                      hostmacro->description = zbx_strdup(NULL, masterhostmacro->description);
                      hostmacro->type = masterhostmacro->type;
      -
      +               hostmacro->flags = 0;
                      zbx_vector_ptr_append(hostmacros, hostmacro);
              }
      

            MVekslers Michael Veksler
            vso Vladislavs Sokurenko
            Team C
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: