@@ -1056,15 +1056,16 @@ static int start_logging()
1056
1056
}
1057
1057
error_header ();
1058
1058
fprintf (stderr , "logging started to the file %s.\n" , alt_fname );
1059
- strncpy (current_log_buf , alt_fname , sizeof (current_log_buf ));
1059
+ strncpy (current_log_buf , alt_fname , sizeof (current_log_buf )- 1 );
1060
1060
current_log_buf [sizeof (current_log_buf )- 1 ]= 0 ;
1061
1061
}
1062
1062
else if (output_type == OUTPUT_SYSLOG )
1063
1063
{
1064
1064
openlog (syslog_ident , LOG_NOWAIT , syslog_facility_codes [syslog_facility ]);
1065
1065
error_header ();
1066
1066
fprintf (stderr , "logging started to the syslog.\n" );
1067
- strncpy (current_log_buf , "[SYSLOG]" , sizeof (current_log_buf ));
1067
+ strncpy (current_log_buf , "[SYSLOG]" , sizeof (current_log_buf )- 1 );
1068
+ compile_time_assert (sizeof current_log_buf > sizeof "[SYSLOG]" );
1068
1069
}
1069
1070
is_active = 1 ;
1070
1071
return 0 ;
@@ -2600,7 +2601,7 @@ static void update_file_path(MYSQL_THD thd,
2600
2601
internal_stop_logging = 0 ;
2601
2602
}
2602
2603
2603
- strncpy (path_buffer , new_name , sizeof (path_buffer ));
2604
+ strncpy (path_buffer , new_name , sizeof (path_buffer )- 1 );
2604
2605
path_buffer [sizeof (path_buffer )- 1 ]= 0 ;
2605
2606
file_path = path_buffer ;
2606
2607
exit_func :
@@ -2653,7 +2654,7 @@ static void update_incl_users(MYSQL_THD thd,
2653
2654
if (!maria_55_started || !debug_server_started )
2654
2655
flogger_mutex_lock (& lock_operations );
2655
2656
mark_always_logged (thd );
2656
- strncpy (incl_user_buffer , new_users , sizeof (incl_user_buffer ));
2657
+ strncpy (incl_user_buffer , new_users , sizeof (incl_user_buffer )- 1 );
2657
2658
incl_user_buffer [sizeof (incl_user_buffer )- 1 ]= 0 ;
2658
2659
incl_users = incl_user_buffer ;
2659
2660
user_coll_fill (& incl_user_coll , incl_users , & excl_user_coll , 1 );
@@ -2672,7 +2673,7 @@ static void update_excl_users(MYSQL_THD thd __attribute__((unused)),
2672
2673
if (!maria_55_started || !debug_server_started )
2673
2674
flogger_mutex_lock (& lock_operations );
2674
2675
mark_always_logged (thd );
2675
- strncpy (excl_user_buffer , new_users , sizeof (excl_user_buffer ));
2676
+ strncpy (excl_user_buffer , new_users , sizeof (excl_user_buffer )- 1 );
2676
2677
excl_user_buffer [sizeof (excl_user_buffer )- 1 ]= 0 ;
2677
2678
excl_users = excl_user_buffer ;
2678
2679
user_coll_fill (& excl_user_coll , excl_users , & incl_user_coll , 0 );
@@ -2804,7 +2805,7 @@ static void update_syslog_ident(MYSQL_THD thd __attribute__((unused)),
2804
2805
void * var_ptr __attribute__((unused )), const void * save )
2805
2806
{
2806
2807
char * new_ident = (* (char * * ) save ) ? * (char * * ) save : empty_str ;
2807
- strncpy (syslog_ident_buffer , new_ident , sizeof (syslog_ident_buffer ));
2808
+ strncpy (syslog_ident_buffer , new_ident , sizeof (syslog_ident_buffer )- 1 );
2808
2809
syslog_ident_buffer [sizeof (syslog_ident_buffer )- 1 ]= 0 ;
2809
2810
syslog_ident = syslog_ident_buffer ;
2810
2811
error_header ();
0 commit comments