From: Christopher Faulet Date: Fri, 12 Feb 2021 15:31:03 +0000 (+0100) Subject: BUG/MINOR: server: Don't call fopen() with server-state filepath set to NULL X-Git-Tag: v2.4-dev8~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8952ea636b03fceb44c8172c4d9725a393e9146d;p=thirdparty%2Fhaproxy.git BUG/MINOR: server: Don't call fopen() with server-state filepath set to NULL 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. --- diff --git a/src/server.c b/src/server.c index e95580fe1c..203e8adc6f 100644 --- a/src/server.c +++ b/src/server.c @@ -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: