Fix for `hostname-whitespace'; thanks to Justin Bradford.
[u/mdw/putty] / plink.c
diff --git a/plink.c b/plink.c
index ed4f134..589de1a 100644 (file)
--- a/plink.c
+++ b/plink.c
@@ -29,6 +29,17 @@ void fatalbox(char *p, ...)
     WSACleanup();
     cleanup_exit(1);
 }
+void modalfatalbox(char *p, ...)
+{
+    va_list ap;
+    fprintf(stderr, "FATAL ERROR: ");
+    va_start(ap, p);
+    vfprintf(stderr, p, ap);
+    va_end(ap);
+    fputc('\n', stderr);
+    WSACleanup();
+    cleanup_exit(1);
+}
 void connection_fatal(char *p, ...)
 {
     va_list ap;
@@ -447,6 +458,21 @@ int main(int argc, char **argv)
      */
     cfg.host[strcspn(cfg.host, ":")] = '\0';
 
+    /*
+     * Remove any remaining whitespace from the hostname.
+     */
+    {
+       int p1 = 0, p2 = 0;
+       while (cfg.host[p2] != '\0') {
+           if (cfg.host[p2] != ' ' && cfg.host[p2] != '\t') {
+               cfg.host[p1] = cfg.host[p2];
+               p1++;
+           }
+           p2++;
+       }
+       cfg.host[p1] = '\0';
+    }
+
     if (!*cfg.remote_cmd_ptr)
        flags |= FLAG_INTERACTIVE;