@@ -2550,8 +2550,9 @@ xtrabackup_copy_datafile(fil_node_t* node, uint thread_n, const char *dest_name=
2550
2550
goto error;
2551
2551
}
2552
2552
2553
- strncpy (dst_name, (dest_name)?dest_name : cursor.rel_path , sizeof (dst_name));
2554
-
2553
+ strncpy (dst_name, dest_name ? dest_name : cursor.rel_path ,
2554
+ sizeof dst_name - 1 );
2555
+ dst_name[sizeof dst_name - 1 ] = ' \0 ' ;
2555
2556
2556
2557
/* Setup the page write filter */
2557
2558
if (xtrabackup_incremental) {
@@ -2871,7 +2872,8 @@ static void dbug_mariabackup_event(const char *event,const char *key)
2871
2872
if (slash)
2872
2873
*slash = ' _' ;
2873
2874
} else {
2874
- strncpy (envvar, event, sizeof (envvar));
2875
+ strncpy (envvar, event, sizeof envvar - 1 );
2876
+ envvar[sizeof envvar - 1 ] = ' \0 ' ;
2875
2877
}
2876
2878
char *sql = getenv (envvar);
2877
2879
if (sql) {
@@ -4536,7 +4538,8 @@ void backup_fix_ddl(void)
4536
4538
const char *extension = is_remote ? " .isl" : " .ibd" ;
4537
4539
name.append (extension);
4538
4540
char buf[FN_REFLEN];
4539
- strncpy (buf, name.c_str (), sizeof (buf));
4541
+ strncpy (buf, name.c_str (), sizeof buf - 1 );
4542
+ buf[sizeof buf - 1 ] = ' \0 ' ;
4540
4543
const char *dbname = buf;
4541
4544
char *p = strchr (buf, ' /' );
4542
4545
if (p == 0 ) {
0 commit comments