Let top(1) use MAXLOGNAME instead of UT_NAMESIZE.

The maximum user login length should have nothing to do with <utmp.h>.
This commit is contained in:
Ed Schouten 2009-12-25 09:02:41 +00:00
parent f45946a8f7
commit 2d86428bba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=200979

View File

@ -30,17 +30,17 @@
* This makes the table size independent of the passwd file size.
*/
#include <sys/param.h>
#include <sys/types.h>
#include <stdio.h>
#include <pwd.h>
#include <utmp.h>
#include "top.local.h"
#include "utils.h"
struct hash_el {
int uid;
char name[UT_NAMESIZE + 1];
char name[MAXLOGNAME];
};
#define is_empty_hash(x) (hash_table[x].name[0] == 0)
@ -129,7 +129,7 @@ int wecare; /* 1 = enter it always, 0 = nice to have */
/* empty or wrong slot -- fill it with new value */
hash_table[hashindex].uid = uid;
(void) strncpy(hash_table[hashindex].name, name, UT_NAMESIZE);
(void) strncpy(hash_table[hashindex].name, name, MAXLOGNAME - 1);
return(hashindex);
}