diff options
Diffstat (limited to 'storage/innobase')
-rw-r--r-- | storage/innobase/dict/dict0dict.cc | 24 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 9 | ||||
-rw-r--r-- | storage/innobase/fts/fts0opt.cc | 23 | ||||
-rw-r--r-- | storage/innobase/include/dict0crea.ic | 10 | ||||
-rw-r--r-- | storage/innobase/row/row0ftsort.cc | 17 | ||||
-rw-r--r-- | storage/innobase/row/row0mysql.cc | 8 |
6 files changed, 47 insertions, 44 deletions
diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index bc9bbad8ec3..78b6d562f13 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -1571,13 +1571,8 @@ dict_table_rename_in_cache( ut_ad(mutex_own(&dict_sys->mutex)); /* store the old/current name to an automatic variable */ - if (strlen(table->name.m_name) + 1 <= sizeof(old_name)) { - strcpy(old_name, table->name.m_name); - } else { - ib::fatal() << "Too long table name: " - << table->name - << ", max length is " << MAX_FULL_NAME_LEN; - } + ut_a(strlen(table->name.m_name) < sizeof old_name); + strcpy(old_name, table->name.m_name); fold = ut_fold_string(new_name); @@ -1767,7 +1762,7 @@ dict_table_rename_in_cache( ulint db_len; char* old_id; - char old_name_cs_filename[MAX_TABLE_NAME_LEN+20]; + char old_name_cs_filename[MAX_FULL_NAME_LEN+1]; uint errors = 0; /* All table names are internally stored in charset @@ -1784,7 +1779,8 @@ dict_table_rename_in_cache( in old_name_cs_filename */ strncpy(old_name_cs_filename, old_name, - MAX_TABLE_NAME_LEN); + MAX_FULL_NAME_LEN); + old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0'; if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) { innobase_convert_to_system_charset( @@ -1806,7 +1802,9 @@ dict_table_rename_in_cache( /* Old name already in my_charset_filename */ strncpy(old_name_cs_filename, old_name, - MAX_TABLE_NAME_LEN); + MAX_FULL_NAME_LEN); + old_name_cs_filename[MAX_FULL_NAME_LEN] + = '\0'; } } @@ -1832,7 +1830,7 @@ dict_table_rename_in_cache( /* This is a generated >= 4.0.18 format id */ - char table_name[MAX_TABLE_NAME_LEN] = ""; + char table_name[MAX_TABLE_NAME_LEN + 1]; uint errors = 0; if (strlen(table->name.m_name) @@ -1847,6 +1845,7 @@ dict_table_rename_in_cache( /* Convert the table name to UTF-8 */ strncpy(table_name, table->name.m_name, MAX_TABLE_NAME_LEN); + table_name[MAX_TABLE_NAME_LEN] = '\0'; innobase_convert_to_system_charset( strchr(table_name, '/') + 1, strchr(table->name.m_name, '/') + 1, @@ -1856,9 +1855,10 @@ dict_table_rename_in_cache( /* Table name could not be converted from charset my_charset_filename to UTF-8. This means that the table name - is already in UTF-8 (#mysql#50). */ + is already in UTF-8 (#mysql50#). */ strncpy(table_name, table->name.m_name, MAX_TABLE_NAME_LEN); + table_name[MAX_TABLE_NAME_LEN] = '\0'; } /* Replace the prefix 'databasename/tablename' diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index d7695b7e9cc..d55cafa8ff2 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -726,6 +726,7 @@ fts_reset_get_doc( memset(get_doc, 0x0, sizeof(*get_doc)); get_doc->index_cache = ind_cache; + get_doc->cache = cache; } ut_ad(ib_vector_size(cache->get_docs) @@ -4759,12 +4760,12 @@ fts_tokenize_document( ut_a(!doc->tokens); ut_a(doc->charset); - doc->tokens = rbt_create_arg_cmp( - sizeof(fts_token_t), innobase_fts_text_cmp, (void*) doc->charset); + doc->tokens = rbt_create_arg_cmp(sizeof(fts_token_t), + innobase_fts_text_cmp, + (void*) doc->charset); if (parser != NULL) { fts_tokenize_param_t fts_param; - fts_param.result_doc = (result != NULL) ? result : doc; fts_param.add_pos = 0; diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index cf862cb8c6d..f91ebcbf2a6 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, 2018, MariaDB Corporation. +Copyright (c) 2016, 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -674,25 +674,27 @@ fts_fetch_index_words( fts_zip_t* zip = static_cast<fts_zip_t*>(user_arg); que_node_t* exp = sel_node->select_list; dfield_t* dfield = que_node_get_val(exp); - short len = static_cast<short>(dfield_get_len(dfield)); + + ut_a(dfield_get_len(dfield) <= FTS_MAX_WORD_LEN); + + uint16 len = uint16(dfield_get_len(dfield)); void* data = dfield_get_data(dfield); /* Skip the duplicate words. */ - if (zip->word.f_len == static_cast<ulint>(len) - && !memcmp(zip->word.f_str, data, zip->word.f_len)) { - + if (zip->word.f_len == len && !memcmp(zip->word.f_str, data, len)) { return(TRUE); } - ut_a(len <= FTS_MAX_WORD_LEN); - - zip->word.f_len = ulint(len); - memcpy(zip->word.f_str, data, zip->word.f_len); + memcpy(zip->word.f_str, data, len); + zip->word.f_len = len; ut_a(zip->zp->avail_in == 0); ut_a(zip->zp->next_in == NULL); /* The string is prefixed by len. */ + /* FIXME: This is not byte order agnostic (InnoDB data files + with FULLTEXT INDEX are not portable between little-endian and + big-endian systems!) */ zip->zp->next_in = reinterpret_cast<byte*>(&len); zip->zp->avail_in = sizeof(len); @@ -720,14 +722,13 @@ fts_fetch_index_words( ut_a(len <= FTS_MAX_WORD_LEN); len = 0; } - break; + continue; case Z_STREAM_END: case Z_BUF_ERROR: case Z_STREAM_ERROR: default: ut_error; - break; } } diff --git a/storage/innobase/include/dict0crea.ic b/storage/innobase/include/dict0crea.ic index 565e4ed1a8c..00e4e54115a 100644 --- a/storage/innobase/include/dict0crea.ic +++ b/storage/innobase/include/dict0crea.ic @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2019, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -68,11 +69,11 @@ dict_create_add_foreign_id( sprintf(id, "%s_ibfk_%lu", name, (ulong) (*id_nr)++); } else { - char table_name[MAX_TABLE_NAME_LEN + 20] = ""; + char table_name[MAX_TABLE_NAME_LEN + 21]; uint errors = 0; - strncpy(table_name, name, - MAX_TABLE_NAME_LEN + 20); + strncpy(table_name, name, (sizeof table_name) - 1); + table_name[(sizeof table_name) - 1] = '\0'; innobase_convert_to_system_charset( strchr(table_name, '/') + 1, @@ -81,7 +82,8 @@ dict_create_add_foreign_id( if (errors) { strncpy(table_name, name, - MAX_TABLE_NAME_LEN + 20); + (sizeof table_name) - 1); + table_name[(sizeof table_name) - 1] = '\0'; } /* no overflow if number < 1e13 */ diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 4e3a4b0c4c7..37d2871d5d1 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -96,8 +96,8 @@ row_merge_create_fts_sort_index( field = dict_index_get_nth_field(new_index, 0); field->name = NULL; field->prefix_len = 0; - field->col = static_cast<dict_col_t*>( - mem_heap_alloc(new_index->heap, sizeof(dict_col_t))); + field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) + dict_col_t(); field->col->prtype = idx_field->col->prtype | DATA_NOT_NULL; field->col->mtype = charset == &my_charset_latin1 ? DATA_VARCHAR : DATA_VARMYSQL; @@ -111,8 +111,8 @@ row_merge_create_fts_sort_index( field = dict_index_get_nth_field(new_index, 1); field->name = NULL; field->prefix_len = 0; - field->col = static_cast<dict_col_t*>( - mem_heap_alloc(new_index->heap, sizeof(dict_col_t))); + field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) + dict_col_t(); field->col->mtype = DATA_INT; *opt_doc_id_size = FALSE; @@ -146,21 +146,16 @@ row_merge_create_fts_sort_index( field->col->prtype = DATA_NOT_NULL | DATA_BINARY_TYPE; - field->col->mbminlen = 0; - field->col->mbmaxlen = 0; - /* The third field is on the word's position in the original doc */ field = dict_index_get_nth_field(new_index, 2); field->name = NULL; field->prefix_len = 0; - field->col = static_cast<dict_col_t*>( - mem_heap_alloc(new_index->heap, sizeof(dict_col_t))); + field->col = new(mem_heap_zalloc(new_index->heap, sizeof(dict_col_t))) + dict_col_t(); field->col->mtype = DATA_INT; field->col->len = 4 ; field->fixed_len = 4; field->col->prtype = DATA_NOT_NULL; - field->col->mbminlen = 0; - field->col->mbmaxlen = 0; return(new_index); } diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 8001b5ff43b..7ae400c8860 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4368,11 +4368,12 @@ row_rename_table_for_mysql( if (!new_is_tmp) { /* Rename all constraints. */ - char new_table_name[MAX_TABLE_NAME_LEN] = ""; - char old_table_utf8[MAX_TABLE_NAME_LEN] = ""; + char new_table_name[MAX_TABLE_NAME_LEN + 1]; + char old_table_utf8[MAX_TABLE_NAME_LEN + 1]; uint errors = 0; strncpy(old_table_utf8, old_name, MAX_TABLE_NAME_LEN); + old_table_utf8[MAX_TABLE_NAME_LEN] = '\0'; innobase_convert_to_system_charset( strchr(old_table_utf8, '/') + 1, strchr(old_name, '/') +1, @@ -4383,6 +4384,7 @@ row_rename_table_for_mysql( my_charset_filename to UTF-8. This means that the table name is already in UTF-8 (#mysql#50). */ strncpy(old_table_utf8, old_name, MAX_TABLE_NAME_LEN); + old_table_utf8[MAX_TABLE_NAME_LEN] = '\0'; } info = pars_info_create(); @@ -4393,6 +4395,7 @@ row_rename_table_for_mysql( old_table_utf8); strncpy(new_table_name, new_name, MAX_TABLE_NAME_LEN); + new_table_name[MAX_TABLE_NAME_LEN] = '\0'; innobase_convert_to_system_charset( strchr(new_table_name, '/') + 1, strchr(new_name, '/') +1, @@ -4403,6 +4406,7 @@ row_rename_table_for_mysql( my_charset_filename to UTF-8. This means that the table name is already in UTF-8 (#mysql#50). */ strncpy(new_table_name, new_name, MAX_TABLE_NAME_LEN); + new_table_name[MAX_TABLE_NAME_LEN] = '\0'; } pars_info_add_str_literal(info, "new_table_utf8", new_table_name); |