X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/8d90b8b27bf086da6245030459ab3e5977313eb0..5fd70d0768f86274b22e73f3cd8f59fec0325e36:/windows/window.c diff --git a/windows/window.c b/windows/window.c index 0ae88cc1..8d13ff91 100644 --- a/windows/window.c +++ b/windows/window.c @@ -617,10 +617,21 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show) } } - /* - * Trim off a colon suffix if it's there. - */ - host[strcspn(host, ":")] = '\0'; + /* + * Trim a colon suffix off the hostname if it's there. In + * order to protect IPv6 address literals against this + * treatment, we do not do this if there's _more_ than one + * colon. + */ + { + char *c = strchr(host, ':'); + + if (c) { + char *d = strchr(c+1, ':'); + if (!d) + *c = '\0'; + } + } /* * Remove any remaining whitespace.