]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Fix for `hostname-whitespace'; thanks to Justin Bradford.
authorSimon Tatham <anakin@pobox.com>
Wed, 16 Oct 2002 11:35:13 +0000 (11:35 +0000)
committerSimon Tatham <anakin@pobox.com>
Wed, 16 Oct 2002 11:35:13 +0000 (11:35 +0000)
[originally from svn r2080]

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

diff --git a/plink.c b/plink.c
index 0d79a98430354c28e56c2857ec85e39159c53d8e..589de1a0104ca3742cbbd4c07d05ebaef66d9761 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 4657091f9d69fb72e7aedba8dc0a26c6b70cb01a..32d24f787b16567e0b98589a0526497e9ef3856d 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 a24d62fbeba392edc761157c2b57634eff794b18..e8df3a46c47993af272703d5b525d8775b0fb49c 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 aa6b6809d838b292097b372e82e2169768589524..ddd7aa921b96bddada2c4091102301e047ea3a96 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';
+       }
     }
 
     /*