summaryrefslogtreecommitdiff
path: root/storage/xtradb/srv
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-03-06 11:22:27 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-03-06 11:22:27 +0200
commitb7612116850d1968dc34d5a2d7b812ebfecf67f2 (patch)
tree31d4fa47eba2ca312848ee1d4833da839aa9cc8c /storage/xtradb/srv
parentb21930fb0fc1a1986adac0e2a911005ad709bfe7 (diff)
downloadmariadb-git-b7612116850d1968dc34d5a2d7b812ebfecf67f2.tar.gz
MDEV-18659: Fix string truncation/overflow in InnoDB and XtraDB
Fix the warnings issued by GCC 8 -Wstringop-truncation and -Wstringop-overflow in InnoDB and XtraDB. This work is motivated by Jan Lindström. The patch mainly differs from his original one as follows: (1) We remove explicit initialization of stack-allocated string buffers. The minimum amount of initialization that is needed is a terminating NUL character. (2) GCC issues a warning for invoking strncpy(dest, src, sizeof dest) because if strlen(src) >= sizeof dest, there would be no terminating NUL byte in dest. We avoid this problem by invoking strncpy() with a limit that is 1 less than the buffer size, and by always writing NUL to the last byte of the buffer. (3) We replace strncpy() with memcpy() or strcpy() in those cases when the result is functionally equivalent. Note: fts_fetch_index_words() never deals with len==UNIV_SQL_NULL. This was enforced by an assertion that limits the maximum length to FTS_MAX_WORD_LEN. Also, the encoding that InnoDB uses for the compressed fulltext index is not byte-order agnostic, that is, InnoDB data files that use FULLTEXT INDEX are not portable between big-endian and little-endian systems.
Diffstat (limited to 'storage/xtradb/srv')
-rw-r--r--storage/xtradb/srv/srv0start.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/storage/xtradb/srv/srv0start.cc b/storage/xtradb/srv/srv0start.cc
index 2553d405a19..941feeb70c7 100644
--- a/storage/xtradb/srv/srv0start.cc
+++ b/storage/xtradb/srv/srv0start.cc
@@ -3,7 +3,7 @@
Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2008, Google Inc.
Copyright (c) 2009, Percona Inc.
-Copyright (c) 2013, 2017, MariaDB Corporation
+Copyright (c) 2013, 2019, MariaDB Corporation.
Portions of this file contain modifications contributed and copyrighted by
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -3476,9 +3476,8 @@ srv_get_meta_data_filename(
if (strncmp(suffix, ".cfg", suffix_len) == 0) {
strcpy(filename, path);
} else {
- ut_ad(strncmp(suffix, ".ibd", suffix_len) == 0);
-
- strncpy(filename, path, len - suffix_len);
+ ut_ad(!strcmp(suffix, ".ibd"));
+ memcpy(filename, path, len - suffix_len);
suffix = filename + (len - suffix_len);
strcpy(suffix, ".cfg");
}