diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-22 11:11:22 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-08-22 12:13:37 +0300 |
commit | 5b29820d800180816abd67f24414eaa0d51dd6b5 (patch) | |
tree | 5a6559af9fb6141b033e240ca78f175372edf0b6 /storage/perfschema | |
parent | 94e6a4fa6ab9f6c6b273819e37da0754df63fee0 (diff) | |
download | mariadb-git-5b29820d800180816abd67f24414eaa0d51dd6b5.tar.gz |
Fix -Wstringop-truncation
For the Sphinx storage engine, this is a functional change (bug fix):
we will ensure that the message buffer is always NUL-terminated.
Diffstat (limited to 'storage/perfschema')
-rw-r--r-- | storage/perfschema/pfs_instr.cc | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/storage/perfschema/pfs_instr.cc b/storage/perfschema/pfs_instr.cc index 44b170469bf..1ea4fcd901b 100644 --- a/storage/perfschema/pfs_instr.cc +++ b/storage/perfschema/pfs_instr.cc @@ -1265,7 +1265,6 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, char dirbuffer[FN_REFLEN]; size_t dirlen; const char *normalized_filename; - int normalized_length; dirlen= dirname_length(safe_filename); if (dirlen == 0) @@ -1296,7 +1295,7 @@ find_or_create_file(PFS_thread *thread, PFS_file_class *klass, *buf_end= '\0'; normalized_filename= buffer; - normalized_length= strlen(normalized_filename); + size_t normalized_length= strlen(normalized_filename); PFS_file **entry; uint retry_count= 0; @@ -1345,7 +1344,7 @@ search: pfs->m_class= klass; pfs->m_enabled= klass->m_enabled && flag_global_instrumentation; pfs->m_timed= klass->m_timed; - strncpy(pfs->m_filename, normalized_filename, normalized_length); + strncpy(pfs->m_filename, normalized_filename, normalized_length + 1); pfs->m_filename[normalized_length]= '\0'; pfs->m_filename_length= normalized_length; pfs->m_file_stat.m_open_count= 1; |