From 809dea34e037ca1638c2f61c1edcbe0b7bcc0ad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 29 Jun 2017 22:06:14 +0300 Subject: [PATCH] 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. --- server/modules/routing/binlogrouter/blr_file.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/binlogrouter/blr_file.c b/server/modules/routing/binlogrouter/blr_file.c index 7e2035652..ad967ad5d 100644 --- a/server/modules/routing/binlogrouter/blr_file.c +++ b/server/modules/routing/binlogrouter/blr_file.c @@ -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];