From cae0c0233cb7c0180bfb7a5bca934b6e57805471 Mon Sep 17 00:00:00 2001 From: simon Date: Wed, 16 Oct 2002 11:35:13 +0000 Subject: [PATCH] Fix for `hostname-whitespace'; thanks to Justin Bradford. git-svn-id: svn://svn.tartarus.org/sgt/putty@2080 cda61777-01e9-0310-a592-d414129be87e --- plink.c | 15 +++++++++++++++ psftp.c | 15 +++++++++++++++ scp.c | 15 +++++++++++++++ window.c | 15 +++++++++++++++ 4 files changed, 60 insertions(+) diff --git a/plink.c b/plink.c index 0d79a984..589de1a0 100644 --- 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 4657091f..32d24f78 100644 --- 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 a24d62fb..e8df3a46 100644 --- 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); diff --git a/window.c b/window.c index aa6b6809..ddd7aa92 100644 --- 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'; + } } /* -- 2.11.0