]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix NULL checks in home.cgi.
authorMichael R Sweet <msweet@msweet.org>
Thu, 13 Nov 2025 17:54:18 +0000 (12:54 -0500)
committerMichael R Sweet <msweet@msweet.org>
Thu, 13 Nov 2025 17:54:18 +0000 (12:54 -0500)
cgi-bin/home.c

index 229746aa742852e69063d15e5b85574fdff05a2f..278e2861ee77377b009df2a96535c23fcc897d40 100644 (file)
@@ -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);