From 5164f8c206e48c00aba2ec3007f309e3840c12eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 4 Nov 2019 15:52:54 +0200 Subject: 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. --- extra/mariabackup/backup_copy.cc | 2 +- extra/mariabackup/changed_page_bitmap.cc | 2 +- extra/mariabackup/xtrabackup.cc | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'extra/mariabackup') diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index b31edfd65c5..64fc26b6762 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -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'; diff --git a/extra/mariabackup/changed_page_bitmap.cc b/extra/mariabackup/changed_page_bitmap.cc index 372d5b62a1d..9212ddb5e6d 100644 --- a/extra/mariabackup/changed_page_bitmap.cc +++ b/extra/mariabackup/changed_page_bitmap.cc @@ -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 diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 40539b1e632..b9cb8a8007a 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -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) { -- cgit v1.2.1