fatal("%s: Cannot find account for uid %ld", __func__,
(long)uid);
- /* No MIN_SIZEOF here - we absolutely *must not* truncate the
- * username (XXX - so check for trunc!) */
- strlcpy(li->username, pw->pw_name, sizeof(li->username));
+ if (strlcpy(li->username, pw->pw_name, sizeof(li->username)) >=
+ sizeof(li->username)) {
+ error("%s: username too long (%lu > max %lu)", __func__,
+ strlen(pw->pw_name), sizeof(li->username) - 1);
+ return NULL;
+ }
if (getlast_entry(li))
return (li);
return (NULL);
}
-
/*
* login_alloc_entry(int, char*, char*, char*) - Allocate and initialise
* a logininfo structure