X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windows%2Fwindow.c;h=8d13ff911754f2abb0a545d7dc779200faea834a;hb=0cc6fb8bfea07360afeac83ba67aceffb56499c8;hp=0ae88cc10e7c963335592fc8655cc541813198f1;hpb=5e2c794424f84ad1b48bb2069723e57813543aa7;p=PuTTY.git 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.