summaryrefslogtreecommitdiff
blob: 21b11080dfa0a717de8dbd576aacd7c764287820 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
diff --git a/acls.c b/acls.c
index 0f98df2..5f26d70 100644
--- a/acls.c
+++ b/acls.c
@@ -178,7 +178,7 @@ struct acluser **up;
 #endif
   (*up)->u_Esc = DefaultEsc;
   (*up)->u_MetaEsc = DefaultMetaEsc;
-  strncpy((*up)->u_name, name, 20);
+  strncpy((*up)->u_name, name, MAXSTR);
   (*up)->u_password = NULL;
   if (pass)
     (*up)->u_password = SaveStr(pass);
@@ -314,8 +314,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 : "", MAXSTR);
+  (*up)->u_password[MAXSTR] = '\0';
   return 0;
 }
 #endif
diff --git a/acls.h b/acls.h
index c41b714..7f20f55 100644
--- a/acls.h
+++ b/acls.h
@@ -36,6 +36,16 @@
 #define ACLBYTE(data, w)   ((data)[(w) >> 3])
 #define ACLBIT(w)   (0x80 >> ((w) & 7))
 
+#include <limits.h>
+
+#ifndef NAME_MAX
+# ifndef MAXNAMELEN
+#  define NAME_MAX 255
+# else
+#  define NAME_MAX MAXNAMELEN
+# endif
+#endif
+
 typedef unsigned char * AclBits;
 
 /*
@@ -73,7 +83,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[NAME_MAX+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/display.h b/display.h
index ef99954..563fcd0 100644
--- a/display.h
+++ b/display.h
@@ -22,6 +22,16 @@
  * $Id: display.h,v 1.9 1994/05/31 12:31:54 mlschroe Exp $ FAU
  */
 
+#include <limits.h>
+
+#ifndef NAME_MAX
+# ifndef MAXNAMELEN
+#  define NAME_MAX 255
+# else
+#  define NAME_MAX MAXNAMELEN
+# endif
+#endif
+
 #ifdef MAPKEYS
 
 #define KMAP_KEYS (T_OCAPS-T_CAPS)
@@ -85,7 +95,7 @@ struct display
   struct win *d_other;		/* pointer to other window */
   int   d_nonblock;		/* -1 don't block if obufmax reached */
 				/* >0: block after nonblock secs */
-  char  d_termname[20 + 1];	/* $TERM */
+  char  d_termname[NAME_MAX + 1]; /* $TERM */
   char	*d_tentry;		/* buffer for tgetstr */
   char	d_tcinited;		/* termcap inited flag */
   int	d_width, d_height;	/* width/height of the screen */
diff --git a/screen.c b/screen.c
index 70741df..6f45b60 100644
--- a/screen.c
+++ b/screen.c
@@ -106,6 +106,16 @@ FILE *dfp;
 #endif
 
 
+#include <limits.h>
+
+#ifndef NAME_MAX
+# ifndef MAXNAMELEN
+#  define NAME_MAX 255
+# else
+#  define NAME_MAX MAXNAMELEN
+# endif
+#endif
+
 extern char Term[], screenterm[], **environ, Termcap[];
 int force_vt = 1;
 int VBellWait, MsgWait, MsgMinWait, SilenceWait;
@@ -877,13 +887,13 @@ char **av;
 
   if (home == 0 || *home == '\0')
     home = ppp->pw_dir;
-  if (strlen(LoginName) > 20)
+  if (strlen(LoginName) > NAME_MAX)
     Panic(0, "LoginName too long - sorry.");
 #ifdef MULTIUSER
-  if (multi && strlen(multi) > 20)
+  if (multi && strlen(multi) > NAME_MAX)
     Panic(0, "Screen owner name too long - sorry.");
 #endif
-  if (strlen(home) > MAXPATHLEN - 25)
+  if (strlen(home) > MAXPATHLEN - NAME_MAX)
     Panic(0, "$HOME too long - sorry.");
 
   attach_tty = "";
diff --git a/screen.h b/screen.h
index 4f9f354..bcaaaf6 100644
--- a/screen.h
+++ b/screen.h
@@ -43,6 +43,15 @@
 #include "comm.h"
 #include "layer.h"
 #include "term.h"
+#include <limits.h>
+
+#ifndef NAME_MAX
+# ifndef MAXNAMELEN
+#  define NAME_MAX 255
+# else
+#  define NAME_MAX MAXNAMELEN
+# endif
+#endif
 
 
 #ifdef DEBUG
@@ -195,26 +204,26 @@ struct msg
       create;
       struct
 	{
-	  char auser[20 + 1];	/* username */
+	  char auser[NAME_MAX + 1];	/* username */
 	  int apid;		/* pid of frontend */
 	  int adaptflag;	/* adapt window size? */
 	  int lines, columns;	/* display size */
 	  char preselect[20];
 	  int esc;		/* his new escape character unless -1 */
 	  int meta_esc;		/* his new meta esc character unless -1 */
-	  char envterm[20 + 1];	/* terminal type */
+	  char envterm[NAME_MAX + 1];	/* terminal type */
 	  int encoding;		/* encoding of display */
 	}
       attach;
       struct 
 	{
-	  char duser[20 + 1];	/* username */
+	  char duser[NAME_MAX + 1];	/* username */
 	  int dpid;		/* pid of frontend */
 	}
       detach;
       struct 
 	{
-	  char auser[20 + 1];	/* username */
+	  char auser[NAME_MAX + 1];	/* username */
 	  int nargs;
 	  char cmd[MAXPATHLEN];	/* command */
 	  int apid;		/* pid of frontend */
diff --git a/socket.c b/socket.c
index 62a73af..1cc9c27 100644
--- a/socket.c
+++ b/socket.c
@@ -45,6 +45,16 @@
 
 #include "extern.h"
 
+#include <limits.h>
+
+#ifndef NAME_MAX
+# ifndef MAXNAMELEN
+#  define NAME_MAX 255
+# else
+#  define NAME_MAX MAXNAMELEN
+# endif
+#endif
+
 static int   CheckPid __P((int));
 static void  ExecCreate __P((struct msg *));
 static void  DoCommandMsg __P((struct msg *));
@@ -1248,7 +1258,7 @@ static void PasswordProcessInput __P((char *, int));
 
 struct pwdata {
   int l;
-  char buf[20 + 1];
+  char buf[NAME_MAX + 1];
   struct msg m;
 };