diff options
author | Damien Miller <djm@mindrot.org> | 2013-12-29 17:40:18 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2013-12-29 17:40:18 +1100 |
commit | 7d97fd9a1cae778c3eacf16e09f5da3689d616c6 (patch) | |
tree | 704fce3feffdc84812588fe63d7e00b45651f122 /loginrec.c | |
parent | 77244afe3b6d013b485e0952eaab89b9db83380f (diff) |
- (djm) [loginrec.c] Check for username truncation when looking up lastlog
entries
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 |