"tests/vscode:/vscode.git/clone" did not exist on "fc731bc67f8ecd07e83aa138b03a073028f9f3f2"
Commit 35667d75 authored by antirez's avatar antirez
Browse files

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.
parent fc0fb0ba
...@@ -1560,7 +1560,7 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) { ...@@ -1560,7 +1560,7 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
* *
* On failure the function logs a warning on the Redis log. */ * On failure the function logs a warning on the Redis log. */
void sentinelFlushConfig(void) { void sentinelFlushConfig(void) {
int fd; int fd = -1;
int saved_hz = server.hz; int saved_hz = server.hz;
int rewrite_status; int rewrite_status;
...@@ -1572,7 +1572,6 @@ void sentinelFlushConfig(void) { ...@@ -1572,7 +1572,6 @@ void sentinelFlushConfig(void) {
if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr; if ((fd = open(server.configfile,O_RDONLY)) == -1) goto werr;
if (fsync(fd) == -1) goto werr; if (fsync(fd) == -1) goto werr;
if (close(fd) == EOF) goto werr; if (close(fd) == EOF) goto werr;
return; return;
werr: werr:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment