From 35667d75c38af8f7fc523dd47fa0751cb7afadac Mon Sep 17 00:00:00 2001 From: antirez Date: Mon, 24 Mar 2014 21:07:44 +0100 Subject: [PATCH] Fixed undefined variable value with certain code paths. In sentinelFlushConfig() fd could be undefined when the following if statement was true: if (rewrite_status == -1) goto werr; This could cause random file descriptors to get closed. --- src/sentinel.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sentinel.c b/src/sentinel.c index be1591c9..fa312586 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1560,7 +1560,7 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) { * * On failure the function logs a warning on the Redis log. */ void sentinelFlushConfig(void) { - int fd; + int fd = -1; int saved_hz = server.hz; int rewrite_status; @@ -1572,7 +1572,6 @@ void sentinelFlushConfig(void) { if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr; if (fsync(fd) == -1) goto werr; if (close(fd) == EOF) goto werr; - return; werr: