From 6bdd959f6ceaa3d4c8094731d3a1e098ed3a1d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 17 Aug 2017 14:17:08 +0300 Subject: [PATCH] Reset client DCB pointer after closing it The client DCB was not reset in one of the cases where it was closed. Also fixed use of overlapping memory addresses in strcpy. --- server/modules/routing/binlogrouter/blr_file.c | 4 +++- server/modules/routing/binlogrouter/blr_master.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/modules/routing/binlogrouter/blr_file.c b/server/modules/routing/binlogrouter/blr_file.c index 2ab742a69..2ffba12e5 100644 --- a/server/modules/routing/binlogrouter/blr_file.c +++ b/server/modules/routing/binlogrouter/blr_file.c @@ -555,7 +555,9 @@ blr_file_create(ROUTER_INSTANCE *router, char *orig_file) { close(router->binlog_fd); spinlock_acquire(&router->binlog_lock); - strcpy(router->binlog_name, file); + int len = strlen(file); + memmove(router->binlog_name, file, len); + router->binlog_name[len] = '\0'; router->binlog_fd = fd; /* Initial position after the magic number */ router->current_pos = BINLOG_MAGIC_SIZE; diff --git a/server/modules/routing/binlogrouter/blr_master.c b/server/modules/routing/binlogrouter/blr_master.c index e3405986e..398367d70 100644 --- a/server/modules/routing/binlogrouter/blr_master.c +++ b/server/modules/routing/binlogrouter/blr_master.c @@ -340,6 +340,7 @@ static void blr_restart_master(ROUTER_INSTANCE *router) { dcb_close(router->client); + router->client = NULL; /* Now it is safe to unleash other threads on this router instance */ spinlock_acquire(&router->lock);