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
@@ -310,9 +310,12 @@ login_get_lastlog(struct logininfo *li, const uid_t uid) 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); @@ -320,7 +323,6 @@ login_get_lastlog(struct logininfo *li, const uid_t uid) return (NULL); } - /* * login_alloc_entry(int, char*, char*, char*) - Allocate and initialise * a logininfo structure |