Fix overlap of router->binlog_name in blr_file_create

A call to strcpy was made in blr_file_create where the function was given
the same pointer as both parameters. To avoid this, the file name is now
copied to a local variable before the router variables are modified.
This commit is contained in:
Markus Mäkelä 2017-06-29 22:06:14 +03:00
parent 9a42709da4
commit 809dea34e0

View File

@ -394,15 +394,18 @@ blr_file_add_magic(int fd)
* @return Non-zero if the fie creation succeeded
*/
static int
blr_file_create(ROUTER_INSTANCE *router, char *file)
blr_file_create(ROUTER_INSTANCE *router, char *orig_file)
{
if (strlen(file) > BINLOG_FNAMELEN)
if (strlen(orig_file) > BINLOG_FNAMELEN)
{
MXS_ERROR("The binlog filename %s is longer than the maximum allowed length %d.",
file, BINLOG_FNAMELEN);
orig_file, BINLOG_FNAMELEN);
return 0;
}
char file[strlen(orig_file) + 1];
strcpy(file, orig_file);
int created = 0;
char err_msg[MXS_STRERROR_BUFLEN];