]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: Don't call fopen() with server-state filepath set to NULL
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Feb 2021 15:31:03 +0000 (16:31 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Feb 2021 15:42:00 +0000 (16:42 +0100)
When a local server-state file is loaded, if its name is too long, the error
is not properly handled, resulting to a call to fopen() with the "filepath"
variable set to NULL. To fix the bug, when this error occurs, we jump to the
next proxy, via a "continue" statement. And we take case to set "filepath"
variable after the error handling to be sure.

This patch should fix the issue #1111. It must be backported as far as 1.6.

src/server.c

index e95580fe1c6888622bf0b973b5d9873ff7a0d2b8..203e8adc6f6c26c1f657f916a178630e7bcce3e7 100644 (file)
@@ -3372,10 +3372,10 @@ void apply_server_state(void)
                                        localfilepathlen += len;
                                        localfilepath[localfilepathlen++] = 0;
                                }
-                               filepath = localfilepath;
  localfileerror:
                                if (localfilepathlen == 0)
-                                       localfilepath[0] = '\0';
+                                       continue;
+                               filepath = localfilepath;
 
                                break;
                        case PR_SRV_STATE_FILE_NONE: