The attached patch fixes the following bug:
http://savannah.gnu.org/bugs/?21653
"LoginName too long - sorry.".
I've added a #define to refer to the maximum length, and bumped that
from the default of 20 to 50. I've tested detach + reattach + ACLs
with the change and all looks good.
Steve
--
Managed Anti-Spam Service
http://mail-scanning.com/
diff --git a/src/acconfig.h b/src/acconfig.h
index 8fda78f..c203461 100644
--- a/src/acconfig.h
+++ b/src/acconfig.h
@@ -39,6 +39,14 @@
#endif
/*
+ * Length of longest username.
+ */
+#ifndef MAX_USERNAME_LEN
+# define MAX_USERNAME_LEN 50
+#endif
+
+
+/*
* Define SOCKDIR to be the directory to contain the named sockets
* screen creates. This should be in a common subdirectory, such as
* /usr/local or /tmp. It makes things a little more secure if you
diff --git a/src/acls.c b/src/acls.c
index 02b182b..a7ff557 100644
--- a/src/acls.c
+++ b/src/acls.c
@@ -183,7 +183,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);
@@ -319,8 +319,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 a62933e..36ab0e7 100644
--- a/src/acls.h
+++ b/src/acls.h
@@ -78,7 +78,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 cf3e39d..a748622 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -973,7 +973,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 c0fdecb..5832f52 100644
--- a/src/screen.h
+++ b/src/screen.h
@@ -201,7 +201,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 */
@@ -215,13 +215,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 */