diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-03-21 08:54:35 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-03-21 08:54:35 +0200 |
commit | 3d1b6f68f1915d9e1ee524b63a78cd412aff0ab4 (patch) | |
tree | 1e514849ed1b94080d6156bffe7278559b012fb6 /extra | |
parent | 630199e7248bce59066850869cf1f932dbf8f994 (diff) | |
download | mariadb-git-3d1b6f68f1915d9e1ee524b63a78cd412aff0ab4.tar.gz |
Mariabackup: Ensure NUL termination in strncpy()
Diffstat (limited to 'extra')
-rw-r--r-- | extra/mariabackup/backup_copy.cc | 3 | ||||
-rw-r--r-- | extra/mariabackup/xtrabackup.cc | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/extra/mariabackup/backup_copy.cc b/extra/mariabackup/backup_copy.cc index be99d49a86f..7543ed89b1f 100644 --- a/extra/mariabackup/backup_copy.cc +++ b/extra/mariabackup/backup_copy.cc @@ -2352,7 +2352,8 @@ static void rocksdb_copy_back() { return; char rocksdb_home_dir[FN_REFLEN]; if (xb_rocksdb_datadir && is_abs_path(xb_rocksdb_datadir)) { - strncpy(rocksdb_home_dir, xb_rocksdb_datadir, sizeof(rocksdb_home_dir)); + strncpy(rocksdb_home_dir, xb_rocksdb_datadir, sizeof rocksdb_home_dir - 1); + rocksdb_home_dir[sizeof rocksdb_home_dir - 1] = '\0'; } else { snprintf(rocksdb_home_dir, sizeof(rocksdb_home_dir), "%s/%s", mysql_data_home, xb_rocksdb_datadir?trim_dotslash(xb_rocksdb_datadir): ROCKSDB_BACKUP_DIR); diff --git a/extra/mariabackup/xtrabackup.cc b/extra/mariabackup/xtrabackup.cc index 2af8c22533f..b9b3c653edc 100644 --- a/extra/mariabackup/xtrabackup.cc +++ b/extra/mariabackup/xtrabackup.cc @@ -2550,8 +2550,9 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name= goto error; } - strncpy(dst_name, (dest_name)?dest_name : cursor.rel_path, sizeof(dst_name)); - + strncpy(dst_name, dest_name ? dest_name : cursor.rel_path, + sizeof dst_name - 1); + dst_name[sizeof dst_name - 1] = '\0'; /* Setup the page write filter */ if (xtrabackup_incremental) { @@ -2871,7 +2872,8 @@ static void dbug_mariabackup_event(const char *event,const char *key) if (slash) *slash = '_'; } else { - strncpy(envvar, event, sizeof(envvar)); + strncpy(envvar, event, sizeof envvar - 1); + envvar[sizeof envvar - 1] = '\0'; } char *sql = getenv(envvar); if (sql) { @@ -4536,7 +4538,8 @@ void backup_fix_ddl(void) const char *extension = is_remote ? ".isl" : ".ibd"; name.append(extension); char buf[FN_REFLEN]; - strncpy(buf, name.c_str(), sizeof(buf)); + strncpy(buf, name.c_str(), sizeof buf - 1); + buf[sizeof buf - 1] = '\0'; const char *dbname = buf; char *p = strchr(buf, '/'); if (p == 0) { |