diff options
author | Alexander Barkov <bar@mariadb.com> | 2022-11-17 17:51:01 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2022-11-17 17:51:01 +0400 |
commit | 6216a2dfa2faabf8abfd3099a6cd46b00cef4115 (patch) | |
tree | 219818f8934e80d7c7f531bc9391ce3a902a32fe /sql | |
parent | df4c3d96a4aba0e5a9af3bd5158cd2049a978130 (diff) | |
download | mariadb-git-6216a2dfa2faabf8abfd3099a6cd46b00cef4115.tar.gz |
MDEV-29473 UBSAN: Signed integer overflow: X * Y cannot be represented in type 'int' in strings/dtoa.c
Fixing a few problems relealed by UBSAN in type_float.test
- multiplication overflow in dtoa.c
- uninitialized Field::geom_type (and Field::srid as well)
- Wrong call-back function types used in combination with SHOW_FUNC.
Changes in the mysql_show_var_func data type definition were not
properly addressed all around the code by the following commits:
b4ff64568c88ab3ce559e7bd39853d9cbf86704a
18feb62feeb833494d003615861b9c78ec008a90
0ee879ff8ac1b80cd9a963015344f5698a81f309
Adding a helper SHOW_FUNC_ENTRY() function and replacing
all mysql_show_var_func declarations using SHOW_FUNC
to SHOW_FUNC_ENTRY, to catch mysql_show_var_func in the future
at compilation time.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/log.cc | 2 | ||||
-rw-r--r-- | sql/mysqld.cc | 28 |
3 files changed, 18 insertions, 14 deletions
diff --git a/sql/field.cc b/sql/field.cc index f430e6209d5..43514347106 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -11073,6 +11073,8 @@ bool Field_vers_trx_id::test_if_equality_guarantees_uniqueness(const Item* item) Column_definition::Column_definition(THD *thd, Field *old_field, Field *orig_field) { + geom_type= Field::GEOM_GEOMETRY; + srid= 0; on_update= NULL; field_name= old_field->field_name; length= old_field->field_length; diff --git a/sql/log.cc b/sql/log.cc index 7ca9b38dc6e..4b071f133f7 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -10501,7 +10501,7 @@ static int show_binlog_vars(THD *thd, SHOW_VAR *var, void *, } static SHOW_VAR binlog_status_vars_top[]= { - {"Binlog", (char *) &show_binlog_vars, SHOW_FUNC}, + SHOW_FUNC_ENTRY("Binlog", &show_binlog_vars), {NullS, NullS, SHOW_LONG} }; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 84c3b9fb0a6..d58f2ed557f 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -8395,7 +8395,9 @@ static int show_ssl_get_cipher_list(THD *thd, SHOW_VAR *var, char *buff, rpl_semi_sync_master_show_##name #define DEF_SHOW_FUNC(name, show_type) \ - static int SHOW_FNAME(name)(MYSQL_THD thd, SHOW_VAR *var, char *buff) \ + static int SHOW_FNAME(name)(MYSQL_THD thd, SHOW_VAR *var, void *buff, \ + system_status_var *status_var, \ + enum_var_type var_type) \ { \ repl_semisync_master.set_export_stats(); \ var->type= show_type; \ @@ -8661,7 +8663,7 @@ SHOW_VAR status_vars[]= { {"Created_tmp_files", (char*) &my_tmp_file_created, SHOW_LONG}, {"Created_tmp_tables", (char*) offsetof(STATUS_VAR, created_tmp_tables_), SHOW_LONG_STATUS}, #ifndef DBUG_OFF - {"Debug", (char*) &debug_status_func, SHOW_FUNC}, + SHOW_FUNC_ENTRY("Debug", &debug_status_func), #endif {"Delayed_errors", (char*) &delayed_insert_errors, SHOW_LONG}, {"Delayed_insert_threads", (char*) &delayed_insert_threads, SHOW_LONG_NOFLUSH}, @@ -8713,7 +8715,7 @@ SHOW_VAR status_vars[]= { {"Handler_tmp_write", (char*) offsetof(STATUS_VAR, ha_tmp_write_count), SHOW_LONG_STATUS}, {"Handler_update", (char*) offsetof(STATUS_VAR, ha_update_count), SHOW_LONG_STATUS}, {"Handler_write", (char*) offsetof(STATUS_VAR, ha_write_count), SHOW_LONG_STATUS}, - {"Key", (char*) &show_default_keycache, SHOW_FUNC}, + SHOW_FUNC_ENTRY("Key", &show_default_keycache), {"Last_query_cost", (char*) offsetof(STATUS_VAR, last_query_cost), SHOW_DOUBLE_STATUS}, {"Max_statement_time_exceeded", (char*) offsetof(STATUS_VAR, max_statement_time_exceeded), SHOW_LONG_STATUS}, {"Master_gtid_wait_count", (char*) offsetof(STATUS_VAR, master_gtid_wait_count), SHOW_LONG_STATUS}, @@ -8737,20 +8739,20 @@ SHOW_VAR status_vars[]= { {"Rows_read", (char*) offsetof(STATUS_VAR, rows_read), SHOW_LONGLONG_STATUS}, {"Rows_tmp_read", (char*) offsetof(STATUS_VAR, rows_tmp_read), SHOW_LONGLONG_STATUS}, #ifdef HAVE_REPLICATION - {"Rpl_semi_sync_master_status", (char*) &SHOW_FNAME(status), SHOW_FUNC}, - {"Rpl_semi_sync_master_clients", (char*) &SHOW_FNAME(clients), SHOW_FUNC}, + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_status", &SHOW_FNAME(status)), + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_clients", &SHOW_FNAME(clients)), {"Rpl_semi_sync_master_yes_tx", (char*) &rpl_semi_sync_master_yes_transactions, SHOW_LONG}, {"Rpl_semi_sync_master_no_tx", (char*) &rpl_semi_sync_master_no_transactions, SHOW_LONG}, - {"Rpl_semi_sync_master_wait_sessions", (char*) &SHOW_FNAME(wait_sessions), SHOW_FUNC}, + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_wait_sessions", &SHOW_FNAME(wait_sessions)), {"Rpl_semi_sync_master_no_times", (char*) &rpl_semi_sync_master_off_times, SHOW_LONG}, {"Rpl_semi_sync_master_timefunc_failures", (char*) &rpl_semi_sync_master_timefunc_fails, SHOW_LONG}, {"Rpl_semi_sync_master_wait_pos_backtraverse", (char*) &rpl_semi_sync_master_wait_pos_backtraverse, SHOW_LONG}, - {"Rpl_semi_sync_master_tx_wait_time", (char*) &SHOW_FNAME(trx_wait_time), SHOW_FUNC}, - {"Rpl_semi_sync_master_tx_waits", (char*) &SHOW_FNAME(trx_wait_num), SHOW_FUNC}, - {"Rpl_semi_sync_master_tx_avg_wait_time", (char*) &SHOW_FNAME(avg_trx_wait_time), SHOW_FUNC}, - {"Rpl_semi_sync_master_net_wait_time", (char*) &SHOW_FNAME(net_wait_time), SHOW_FUNC}, - {"Rpl_semi_sync_master_net_waits", (char*) &SHOW_FNAME(net_wait_num), SHOW_FUNC}, - {"Rpl_semi_sync_master_net_avg_wait_time", (char*) &SHOW_FNAME(avg_net_wait_time), SHOW_FUNC}, + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_tx_wait_time", &SHOW_FNAME(trx_wait_time)), + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_tx_waits", &SHOW_FNAME(trx_wait_num)), + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_tx_avg_wait_time", &SHOW_FNAME(avg_trx_wait_time)), + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_net_wait_time", &SHOW_FNAME(net_wait_time)), + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_net_waits", &SHOW_FNAME(net_wait_num)), + SHOW_FUNC_ENTRY("Rpl_semi_sync_master_net_avg_wait_time", &SHOW_FNAME(avg_net_wait_time)), {"Rpl_semi_sync_master_request_ack", (char*) &rpl_semi_sync_master_request_ack, SHOW_LONGLONG}, {"Rpl_semi_sync_master_get_ack", (char*)&rpl_semi_sync_master_get_ack, SHOW_LONGLONG}, {"Rpl_semi_sync_slave_status", (char*) &rpl_semi_sync_slave_status, SHOW_BOOL}, @@ -8858,7 +8860,7 @@ SHOW_VAR status_vars[]= { {"Uptime_since_flush_status",(char*) &show_flushstatustime, SHOW_SIMPLE_FUNC}, #endif #ifdef WITH_WSREP - {"wsrep", (char*) &wsrep_show_status, SHOW_FUNC}, + SHOW_FUNC_ENTRY("wsrep", &wsrep_show_status), #endif {NullS, NullS, SHOW_LONG} }; |