-
Problem report
-
Resolution: Duplicate
-
Trivial
-
7.0.0beta2
-
None
Moved from ZBXNEXT-6144 (33):
Uninitialized variables more_history, more_discovery, more_areg in send_proxy_data():
static void send_proxy_data(zbx_socket_t *sock, const zbx_timespec_t *ts, const zbx_config_comms_args_t *config_comms, zbx_get_program_type_f get_program_type_cb) { struct zbx_json j; zbx_uint64_t areg_lastid = 0, history_lastid = 0, discovery_lastid = 0; char *error = NULL, *buffer = NULL; int availability_ts, more_history, more_discovery, more_areg, proxy_delay, more; ... zbx_pb_history_get_rows(&j, &history_lastid, &more_history); <-- more_history uninitialized zbx_pb_discovery_get_rows(&j, &discovery_lastid, &more_discovery); <-- more_discovery uninitialied zbx_pb_autoreg_get_rows(&j, &areg_lastid, &more_areg); <-- more_areg uninitialized ...
lead to logging unpredictable values in
int zbx_pb_history_get_rows(struct zbx_json *j, zbx_uint64_t *lastid, int *more) { int state, ret; zabbix_log(LOG_LEVEL_DEBUG, "In %s() lastid:" ZBX_FS_UI64 ", more:" ZBX_FS_UI64, __func__, *lastid, *more); <-- '*more' is of type 'int' and should be '%d', not ZBX_FS_UI64
and
int zbx_pb_discovery_get_rows(struct zbx_json *j, zbx_uint64_t *lastid, int *more) { int state, ret; zabbix_log(LOG_LEVEL_DEBUG, "In %s() lastid:" ZBX_FS_UI64 ", more:" ZBX_FS_UI64, __func__, *lastid, *more); <-- '*more' is of type 'int' and should be '%d', not ZBX_FS_UI64
and
int zbx_pb_autoreg_get_rows(struct zbx_json *j, zbx_uint64_t *lastid, int *more) { int ret, state; zabbix_log(LOG_LEVEL_DEBUG, "In %s() lastid:" ZBX_FS_UI64 ", more:" ZBX_FS_UI64, __func__, *lastid, *more); <-- '*more' is of type 'int' and should be '%d', not ZBX_FS_UI64
Not a big problem, though - uninitialized variables and incorrect ZBX_FS_UI64 affect only debug logging. Later the variables are always initialized.