diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-04 15:52:54 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-11-04 15:52:54 +0200 |
commit | 5164f8c206e48c00aba2ec3007f309e3840c12eb (patch) | |
tree | d0129020d8f223a0a8d8be6d01200a52a493fd4c /extra/mariabackup | |
parent | eb56339b6656da991aa2e25de4d6f655f0bbe213 (diff) | |
download | mariadb-git-5164f8c206e48c00aba2ec3007f309e3840c12eb.tar.gz |
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.
Diffstat (limited to 'extra/mariabackup')
-rw-r--r-- | extra/mariabackup/backup_copy.cc | 2 | ||||
-rw-r--r-- | extra/mariabackup/changed_page_bitmap.cc | 2 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 3 |
3 files changed, 4 insertions, 3 deletions
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) { |