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

Unconditional 64-bit code in proxy configuration receiving code

XMLWordPrintable

    • Prev.Sprint, S24-W40/41
    • 1

      When building on i386 OpenBSD 7.5, the compiler emitted warnings for code in the src/libs/zbxcomms/comms.c module for comparisons of ZBX_MAX_RECV_LARGE_DATA_SIZE against size_t types, where the ZBX_MAX_RECV_LARGE_DATA_SIZE value is always out of the range of a size_t on a 32-bit system.

      This is because on non-Windows systems we unconditionally define this macro to the value of 16 gibibytes (i.e. 171798691824 bytes), which far exceeds the range of a 32-bit integer (42949672956 bytes; which size_t is on 32-bit platforms).

      The compiler emits the warning only for the comparisons. However, the same macro is used in the zbx_tcp_recv_context_init() function that takes a flags parameter and initializes a zbx_tcp_recv_context_t structure. If the ZBX_TCP_LARGE bit is set in flags, we set the max_len member of the structure to the value of ZBX_MAX_RECV_LARGE_DATA_SIZE. The max_len member is of type zbx_uint64_t. This member (and the expected_len and reserved members) should be of type size_t.

      We unconditionally set the ZBX_TCP_LARGE flags bit in calls to zbx_tcp_recv_ext in the src/zabbix_proxy/proxyconfigwrite/proxyconfigwrite.c module and the src/libs/zbxtrapper/trapper.c:1343 module, as well as in src/zabbix_proxy/proxyconfig/proxyconfig.c, in the process_configuration_sync function, where we call zbx_get_data_from_server() which uses the macro zbx_tcp_recv_large that is a warpper around zbx_tcp_recv_ext that sets the ZBX_TCP_LARGE bit in flags.

      At a quick glance, at no point do we ever read more than SIZE_MAX bytes, as the callers of these functions either pass size_t or ssize_t types (cast or otherwise) for sizes to these reads.

      The build log is pasted below

      $ make V=0 -s
      Making all in zbxcomms
      ..
      comms.c:822:35: warning: result of comparison of constant 17179869184 with expression of type 'size_t' (aka 'unsigned long') is always false [-Wtautological-constant-out-of-range-compare]
              if (ZBX_MAX_RECV_LARGE_DATA_SIZE < len)
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~
      comms.c:829:35: warning: result of comparison of constant 17179869184 with expression of type 'size_t' (aka 'unsigned long') is always false [-Wtautological-constant-out-of-range-compare]
              if (ZBX_MAX_RECV_LARGE_DATA_SIZE < reserved)
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~
      2 warnings generated.
      *** Error 1 in src/libs/zbxcomms (Makefile:576 'libzbxcomms_a-tls_openssl.o': cc -DHAVE_CONFIG_H -I../../../include/common -I../../../includ...)
      *** Error 1 in src/libs (Makefile:664 'all-recursive')
      *** Error 1 in src (Makefile:529 'all-recursive')
      *** Error 1 in /home/jxl/zabbix (Makefile:581 'all-recursive')
      $ uname -srm
      OpenBSD 7.5 i386
      $
      

            vso Vladislavs Sokurenko
            jlambda Juris Lambda
            Team C
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:

                Estimated:
                Original Estimate - 16h Original Estimate - 16h
                16h
                Remaining:
                Time Spent - 5h Remaining Estimate - 13h
                13h
                Logged:
                Time Spent - 5h Remaining Estimate - 13h
                5h