summaryrefslogtreecommitdiff
path: root/loginrec.c
diff options
context:
space:
mode:
Diffstat (limited to 'loginrec.c')
-rw-r--r--loginrec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/loginrec.c b/loginrec.c
index 59e8a44ee..4219b9aef 100644
--- a/loginrec.c
+++ b/loginrec.c
@@ -310,9 +310,13 @@ login_get_lastlog(struct logininfo *li, const uid_t uid)
310 fatal("%s: Cannot find account for uid %ld", __func__, 310 fatal("%s: Cannot find account for uid %ld", __func__,
311 (long)uid); 311 (long)uid);
312 312
313 /* No MIN_SIZEOF here - we absolutely *must not* truncate the 313 if (strlcpy(li->username, pw->pw_name, sizeof(li->username)) >=
314 * username (XXX - so check for trunc!) */ 314 sizeof(li->username)) {
315 strlcpy(li->username, pw->pw_name, sizeof(li->username)); 315 error("%s: username too long (%lu > max %lu)", __func__,
316 (unsigned long)strlen(pw->pw_name),
317 (unsigned long)sizeof(li->username) - 1);
318 return NULL;
319 }
316 320
317 if (getlast_entry(li)) 321 if (getlast_entry(li))
318 return (li); 322 return (li);
@@ -320,7 +324,6 @@ login_get_lastlog(struct logininfo *li, const uid_t uid)
320 return (NULL); 324 return (NULL);
321} 325}
322 326
323
324/* 327/*
325 * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise 328 * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise
326 * a logininfo structure 329 * a logininfo structure