diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | loginrec.c | 10 |
2 files changed, 10 insertions, 4 deletions
@@ -1,3 +1,7 @@ | |||
1 | 20131229 | ||
2 | - (djm) [loginrec.c] Check for username truncation when looking up lastlog | ||
3 | entries | ||
4 | |||
1 | 20131221 | 5 | 20131221 |
2 | - (dtucker) [regress/keytype.sh] Actually test ecdsa key types. | 6 | - (dtucker) [regress/keytype.sh] Actually test ecdsa key types. |
3 | 7 | ||
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 |