diff options
Diffstat (limited to 'loginrec.c')
-rw-r--r-- | loginrec.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/loginrec.c b/loginrec.c index 59e8a44ee..8844db540 100644 --- a/loginrec.c +++ b/loginrec.c | |||
@@ -310,9 +310,12 @@ 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 | strlen(pw->pw_name), sizeof(li->username) - 1); | ||
317 | return NULL; | ||
318 | } | ||
316 | 319 | ||
317 | if (getlast_entry(li)) | 320 | if (getlast_entry(li)) |
318 | return (li); | 321 | return (li); |
@@ -320,7 +323,6 @@ login_get_lastlog(struct logininfo *li, const uid_t uid) | |||
320 | return (NULL); | 323 | return (NULL); |
321 | } | 324 | } |
322 | 325 | ||
323 | |||
324 | /* | 326 | /* |
325 | * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise | 327 | * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise |
326 | * a logininfo structure | 328 | * a logininfo structure |