From c1aa031d9354f6b1a4212b0ac9178411dc6477f9 Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Wed, 10 Nov 2010 22:51:20 -0500 Subject: Increase the maximum username length (to 50, defined in MAX_USERNAME_LEN). Apply patch http://www.mail-archive.com/screen-devel@gnu.org/msg00186.html by Steve Kemp with minor changes. This commit resolves bug #21653. --- src/acls.c | 6 +++--- src/acls.h | 9 ++++++++- src/screen.c | 2 +- src/screen.h | 6 +++--- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/acls.c b/src/acls.c index e728bb8..4d0c20f 100644 --- a/src/acls.c +++ b/src/acls.c @@ -182,7 +182,7 @@ struct acluser **up; #endif (*up)->u_Esc = DefaultEsc; (*up)->u_MetaEsc = DefaultMetaEsc; - strncpy((*up)->u_name, name, 20); + strncpy((*up)->u_name, name, MAX_USERNAME_LEN); (*up)->u_password = NULL; if (pass) (*up)->u_password = SaveStr(pass); @@ -318,8 +318,8 @@ struct acluser **up; return UserAdd(name, pass, up); if (!strcmp(name, "nobody")) /* he remains without password */ return -1; - strncpy((*up)->u_password, pass ? pass : "", 20); - (*up)->u_password[20] = '\0'; + strncpy((*up)->u_password, pass ? pass : "", MAX_USERNAME_LEN); + (*up)->u_password[MAX_USERNAME_LEN] = '\0'; return 0; } #endif diff --git a/src/acls.h b/src/acls.h index 907e953..5b24066 100644 --- a/src/acls.h +++ b/src/acls.h @@ -26,6 +26,13 @@ **************************************************************** */ +/* + * Length of longest username. + */ +#ifndef MAX_USERNAME_LEN +# define MAX_USERNAME_LEN 50 +#endif + #ifdef MULTIUSER /* three known bits: */ @@ -78,7 +85,7 @@ struct plop typedef struct acluser { struct acluser *u_next; /* continue the main user list */ - char u_name[20+1]; /* login name how he showed up */ + char u_name[MAX_USERNAME_LEN+1]; /* login name how he showed up */ char *u_password; /* his password (may be NullStr). */ int u_checkpassword; /* nonzero if this u_password is valid */ int u_detachwin; /* the window where he last detached */ diff --git a/src/screen.c b/src/screen.c index 3dde3b4..91889f6 100644 --- a/src/screen.c +++ b/src/screen.c @@ -978,7 +978,7 @@ char **av; if (home == 0 || *home == '\0') home = ppp->pw_dir; - if (strlen(LoginName) > 20) + if (strlen(LoginName) > MAX_USERNAME_LEN) Panic(0, "LoginName too long - sorry."); #ifdef MULTIUSER if (multi && strlen(multi) > 20) diff --git a/src/screen.h b/src/screen.h index 5c93f32..73c17ba 100644 --- a/src/screen.h +++ b/src/screen.h @@ -207,7 +207,7 @@ struct msg create; struct { - char auser[20 + 1]; /* username */ + char auser[MAX_USERNAME_LEN + 1]; /* username */ int apid; /* pid of frontend */ int adaptflag; /* adapt window size? */ int lines, columns; /* display size */ @@ -221,13 +221,13 @@ struct msg attach; struct { - char duser[20 + 1]; /* username */ + char duser[MAX_USERNAME_LEN + 1]; /* username */ int dpid; /* pid of frontend */ } detach; struct { - char auser[20 + 1]; /* username */ + char auser[MAX_USERNAME_LEN + 1]; /* username */ int nargs; char cmd[MAXPATHLEN]; /* command */ int apid; /* pid of frontend */ -- cgit v1.2.1