uint64_decimal() incorrectly output 0 as "" instead of "0". This only affected
[sgt/putty] / psftp.c
diff --git a/psftp.c b/psftp.c
index e5374c5..66c5994 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -1870,7 +1870,7 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
 
     /* See if host is of the form user@host */
     if (cfg.host[0] != '\0') {
-       char *atsign = strchr(cfg.host, '@');
+       char *atsign = strrchr(cfg.host, '@');
        /* Make sure we're not overflowing the user field */
        if (atsign) {
            if (atsign - cfg.host < sizeof cfg.username) {
@@ -1907,10 +1907,9 @@ static int psftp_connect(char *userhost, char *user, int portnumber)
        cfg.username[sizeof(cfg.username) - 1] = '\0';
     }
     if (!cfg.username[0]) {
-       printf("login as: ");
-       fflush(stdout);
-       if (!fgets(cfg.username, sizeof(cfg.username), stdin)) {
-           fprintf(stderr, "psftp: aborting\n");
+       if (!console_get_line("login as: ",
+                             cfg.username, sizeof(cfg.username), FALSE)) {
+           fprintf(stderr, "psftp: no username, aborting\n");
            cleanup_exit(1);
        } else {
            int len = strlen(cfg.username);