Fix for `hostname-whitespace'; thanks to Justin Bradford.
[u/mdw/putty] / scp.c
diff --git a/scp.c b/scp.c
index a24d62f..e8df3a4 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -512,6 +512,21 @@ static void do_cmd(char *host, char *user, char *cmd)
      */
     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';
+    }
+
     /* Set username */
     if (user != NULL && user[0] != '\0') {
        strncpy(cfg.username, user, sizeof(cfg.username) - 1);