From: Michael R Sweet Date: Thu, 13 Nov 2025 17:54:18 +0000 (-0500) Subject: Fix NULL checks in home.cgi. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a0bfeb51d9481aaeec816bc405087b55dd30458b;p=thirdparty%2Fcups.git Fix NULL checks in home.cgi. --- diff --git a/cgi-bin/home.c b/cgi-bin/home.c index 229746aa74..278e2861ee 100644 --- a/cgi-bin/home.c +++ b/cgi-bin/home.c @@ -278,10 +278,10 @@ finish_login(void) } // Get the redirect URL... - if (!strcmp(server_name, "localhost")) - snprintf(redirect_uri, sizeof(redirect_uri), "http://127.0.0.1:%s/", server_port); + if (!server_name || !strcmp(server_name, "localhost")) + snprintf(redirect_uri, sizeof(redirect_uri), "http://127.0.0.1%s%s/", server_port ? ":" : "", server_port ? server_port : ""); else - snprintf(redirect_uri, sizeof(redirect_uri), "%s://%s:%s/", getenv("HTTPS") ? "https" : "http", server_name, server_port); + snprintf(redirect_uri, sizeof(redirect_uri), "%s://%s%s%s/", getenv("HTTPS") ? "https" : "http", server_name, server_port ? ":" : "", server_port ? server_port : ""); fprintf(stderr, "DEBUG2: finish_login: redirect_uri=\"%s\"\n", redirect_uri);