Fix for `hostname-whitespace'; thanks to Justin Bradford.
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 16 Oct 2002 11:35:13 +0000 (11:35 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Wed, 16 Oct 2002 11:35:13 +0000 (11:35 +0000)
git-svn-id: svn://svn.tartarus.org/sgt/putty@2080 cda61777-01e9-0310-a592-d414129be87e

plink.c
psftp.c
scp.c
window.c

diff --git a/plink.c b/plink.c
index 0d79a98..589de1a 100644 (file)
--- a/plink.c
+++ b/plink.c
@@ -458,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;
 
diff --git a/psftp.c b/psftp.c
index 4657091..32d24f7 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -1745,6 +1745,21 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
      */
     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);
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);
index aa6b680..ddd7aa9 100644 (file)
--- a/window.c
+++ b/window.c
@@ -430,6 +430,21 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
         * Trim a colon suffix off the hostname if it's there.
         */
        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';
+       }
     }
 
     /*