]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Semi-bug "long-usernames":
authorJacob Nevins <jacobn@chiark.greenend.org.uk>
Thu, 12 Sep 2002 16:05:05 +0000 (16:05 +0000)
committerJacob Nevins <jacobn@chiark.greenend.org.uk>
Thu, 12 Sep 2002 16:05:05 +0000 (16:05 +0000)
Bump username storage from 32 to 100 chars. Also replaced a couple of magic
numbers with sizeof in ssh.c.
I don't believe this is going to startle any of the protocols PuTTY talks.

[originally from svn r1952]

putty.h
ssh.c

diff --git a/putty.h b/putty.h
index e98bd7da1a04486cef4165f39f05e1b69a14239c..e2a7fea75dd985791392239bdbb3914d49a69709 100644 (file)
--- a/putty.h
+++ b/putty.h
@@ -276,8 +276,8 @@ typedef struct {
     char termtype[32];
     char termspeed[32];
     char environmt[1024];             /* VAR\tvalue\0VAR\tvalue\0\0 */
-    char username[32];
-    char localusername[32];
+    char username[100];
+    char localusername[100];
     int rfc_environ;
     int passive_telnet;
     /* Keyboard options */
diff --git a/ssh.c b/ssh.c
index 58b6b4279a6eacd7a1d51df13d0548a43270f2c5..b2859651de65500ea1cfb8a7b7758ad974dedebb 100644 (file)
--- a/ssh.c
+++ b/ssh.c
@@ -2362,8 +2362,8 @@ static int do_ssh1_login(unsigned char *in, int inlen, int ispkt)
                c_write_str("\r\n");
            }
        } else {
-           strncpy(username, cfg.username, 99);
-           username[99] = '\0';
+           strncpy(username, cfg.username, sizeof(username));
+           username[sizeof(username)-1] = '\0';
        }
 
        send_packet(SSH1_CMSG_USER, PKT_STR, username, PKT_END);
@@ -4182,8 +4182,8 @@ static void do_ssh2_authconn(unsigned char *in, int inlen, int ispkt)
            username[strcspn(username, "\n\r")] = '\0';
        } else {
            char stuff[200];
-           strncpy(username, cfg.username, 99);
-           username[99] = '\0';
+           strncpy(username, cfg.username, sizeof(username));
+           username[sizeof(username)-1] = '\0';
            if ((flags & FLAG_VERBOSE) || (flags & FLAG_INTERACTIVE)) {
                sprintf(stuff, "Using username \"%s\".\r\n", username);
                c_write_str(stuff);