]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: check return value of fopen() in apply_server_state()
authorVedran Furac <vedranf@haproxy.com>
Wed, 16 Oct 2019 12:49:38 +0000 (14:49 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 21 Oct 2019 14:00:24 +0000 (16:00 +0200)
fopen() can return NULL when state file is missing. This patch adds a
check of fopen() return value so we can skip processing in such case.

No backport needed.

src/server.c

index df0dcbfed74c6aa18b7ee1a38458fb22a858ff9d..6b740240eed3b3cbaa7e405adfe24d43313d1ecc 100644 (file)
@@ -3595,6 +3595,8 @@ void apply_server_state(void)
                f = fopen(globalfilepath, "r");
                if (errno)
                        ha_warning("Can't open global server state file '%s': %s\n", globalfilepath, strerror(errno));
+               if (!f)
+                       goto out_load_server_state_in_tree;
 
                global_file_version = srv_state_get_version(f);
                if (global_file_version == 0)