Commit 5164f8c2 authored by Marko Mäkelä's avatar Marko Mäkelä

Fix GCC 9.2.1 -Wstringop-truncation

dict_table_rename_in_cache(): Use strcpy() instead of strncpy(),
because they are known to be equivalent in this case (the length
of old_name was already validated).

mariabackup: Invoke strncpy() with one less than the buffer size,
and explicitly add NUL as the last byte of the buffer.
parent eb56339b
......@@ -467,7 +467,7 @@ struct datafile_cur_t {
{
memset(rel_path, 0, sizeof rel_path);
if (filename) {
strncpy(abs_path, filename, sizeof abs_path);
strncpy(abs_path, filename, sizeof abs_path - 1);
abs_path[(sizeof abs_path) - 1] = 0;
} else {
abs_path[0] = '\0';
......
......@@ -390,7 +390,7 @@ log_online_setup_bitmap_file_range(
bitmap_files->files[array_pos].seq_num = file_seq_num;
strncpy(bitmap_files->files[array_pos].name,
bitmap_dir_file_info.name, FN_REFLEN);
bitmap_dir_file_info.name, FN_REFLEN - 1);
bitmap_files->files[array_pos].name[FN_REFLEN - 1]
= '\0';
bitmap_files->files[array_pos].start_lsn
......
......@@ -2425,7 +2425,8 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n)
goto error;
}
strncpy(dst_name, cursor.rel_path, sizeof(dst_name));
strncpy(dst_name, cursor.rel_path, sizeof dst_name - 1);
dst_name[sizeof dst_name - 1] = '\0';
/* Setup the page write filter */
if (xtrabackup_incremental) {
......
......@@ -1850,8 +1850,7 @@ dict_table_rename_in_cache(
/* The old table name in my_charset_filename is stored
in old_name_cs_filename */
strncpy(old_name_cs_filename, old_name,
MAX_FULL_NAME_LEN);
strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0';
if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) {
......@@ -1873,8 +1872,7 @@ dict_table_rename_in_cache(
} else {
/* Old name already in
my_charset_filename */
strncpy(old_name_cs_filename, old_name,
MAX_FULL_NAME_LEN);
strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN]
= '\0';
}
......
......@@ -1856,8 +1856,7 @@ dict_table_rename_in_cache(
/* The old table name in my_charset_filename is stored
in old_name_cs_filename */
strncpy(old_name_cs_filename, old_name,
MAX_FULL_NAME_LEN);
strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN] = '\0';
if (strstr(old_name, TEMP_TABLE_PATH_PREFIX) == NULL) {
......@@ -1879,8 +1878,7 @@ dict_table_rename_in_cache(
} else {
/* Old name already in
my_charset_filename */
strncpy(old_name_cs_filename, old_name,
MAX_FULL_NAME_LEN);
strcpy(old_name_cs_filename, old_name);
old_name_cs_filename[MAX_FULL_NAME_LEN]
= '\0';
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment