From 3b9be93fdab81e27d68814aa794807897055af0d Mon Sep 17 00:00:00 2001 From: antirez Date: Thu, 30 Nov 2017 18:30:06 +0100 Subject: [PATCH] Prevent corruption of server.executable after DEBUG RESTART. Doing the following ended with a broken server.executable: 1. Start Redis with src/redis-server 2. Send CONFIG SET DIR /tmp/ 3. Send DEBUG RESTART At this point we called execve with an argv[0] that is no longer related to the new path. So after the restart the absolute path of the executable is recomputed in the wrong way. With this fix we pass the absolute path already computed as argv[0]. --- src/server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/server.c b/src/server.c index e56b542a..7498a25f 100644 --- a/src/server.c +++ b/src/server.c @@ -1583,6 +1583,8 @@ int restartServer(int flags, mstime_t delay) { /* Execute the server with the original command line. */ if (delay) usleep(delay*1000); + zfree(server.exec_argv[0]); + server.exec_argv[0] = zstrdup(server.executable); execve(server.executable,server.exec_argv,environ); /* If an error occurred here, there is nothing we can do, but exit. */