Use roundup(MAXLOGNAME, sizeof(long)) as e_login/s_login arrays size

instead of all hardcoded assumptions historically used
(i.e. sizeof(long) == 4)

Use MAXLOGNAME == 17 for stricter setlogin() size checking. Since
it rounds up to 20, all sizes remains the same
This commit is contained in:
Andrey A. Chernov 1997-03-03 09:51:15 +00:00
parent 1ffae4a6dd
commit e91f3cb0c3
3 changed files with 7 additions and 7 deletions

View file

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)param.h 8.3 (Berkeley) 4/4/95
* $Id: param.h,v 1.24 1997/03/03 08:05:03 ache Exp $
* $Id: param.h,v 1.25 1997/03/03 08:34:08 ache Exp $
*/
#ifndef _SYS_PARAM_H_
@ -59,13 +59,13 @@
* Redefined constants are from POSIX 1003.1 limits file.
*
* MAXCOMLEN should be >= sizeof(ac_comm) (see <acct.h>)
* MAXLOGNAME should be >= UT_NAMESIZE+1 (see <utmp.h>)
* MAXLOGNAME should be == UT_NAMESIZE+1 (see <utmp.h>)
*/
#include <sys/syslimits.h>
#define MAXCOMLEN 16 /* max command name remembered */
#define MAXINTERP 32 /* max interpreter file name length */
#define MAXLOGNAME 20 /* max login name length (incl. NUL) */
#define MAXLOGNAME 17 /* max login name length (incl. NUL) */
#define MAXUPRC CHILD_MAX /* max simultaneous processes */
#define NCARGS ARG_MAX /* max bytes for an exec function */
#define NGROUPS NGROUPS_MAX /* max number groups */

View file

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)proc.h 8.15 (Berkeley) 5/19/95
* $Id$
* $Id: proc.h,v 1.32 1997/02/22 09:45:41 peter Exp $
*/
#ifndef _SYS_PROC_H_
@ -57,7 +57,7 @@ struct session {
struct proc *s_leader; /* Session leader. */
struct vnode *s_ttyvp; /* Vnode of controlling terminal. */
struct tty *s_ttyp; /* Controlling terminal. */
char s_login[MAXLOGNAME]; /* Setlogin() name. */
char s_login[roundup(MAXLOGNAME, sizeof(long))]; /* Setlogin() name. */
};
/*

View file

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)user.h 8.2 (Berkeley) 9/23/93
* $Id: user.h,v 1.12 1997/02/22 09:46:23 peter Exp $
* $Id: user.h,v 1.13 1997/03/03 08:34:08 ache Exp $
*/
#ifndef _SYS_USER_H_
@ -83,7 +83,7 @@ struct kinfo_proc {
long e_flag;
#define EPROC_CTTY 0x01 /* controlling tty vnode active */
#define EPROC_SLEADER 0x02 /* session leader */
char e_login[MAXLOGNAME]; /* setlogin() name */
char e_login[roundup(MAXLOGNAME, sizeof(long))]; /* setlogin() name */
long e_spare[2];
} kp_eproc;
};