-
Problem report
-
Resolution: Fixed
-
Major
-
None
-
OpenBSD 7.5, i386
-
S24-W40/41, S24-W44/45
-
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 $
- caused by
-
ZBXNEXT-6840 Proxy fails to receive large configuration
- Closed