From 5fd70d0768f86274b22e73f3cd8f59fec0325e36 Mon Sep 17 00:00:00 2001 From: simon Date: Sun, 4 Aug 2013 19:32:10 +0000 Subject: [PATCH] Reinstate a piece of code accidentally removed in r9214, where Windows PuTTY does not trim a colon suffix off the hostname if it contains _more than one_ colon. This allows IPv6 literals to be entered. (Really we need to do a much bigger revamp of all uses of hostnames to arrange that square-bracketed IPv6 literals work consistently, but this at least removes a regression over 0.62.) git-svn-id: svn://svn.tartarus.org/sgt/putty@9983 cda61777-01e9-0310-a592-d414129be87e --- windows/window.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) 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. -- 2.11.0