summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pwd_mkdb
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2009-05-20 08:32:25 +0000
committerbrian <brian@FreeBSD.org>2009-05-20 08:32:25 +0000
commit0c0feffc9571ecede7b49c13f5f0d5590c6a08df (patch)
tree827f95e98910e6a04226a6ea63499207df8b1bd5 /usr.sbin/pwd_mkdb
parent5b643b0ede28a9a6134496554e7a6ead6ceefb50 (diff)
downloadFreeBSD-src-0c0feffc9571ecede7b49c13f5f0d5590c6a08df.zip
FreeBSD-src-0c0feffc9571ecede7b49c13f5f0d5590c6a08df.tar.gz
Verify that the username length is smaller than MAXLOGNAME when
asked to verify a passwd file (pwd_mkdb -C). Entries with oversized usernames are still permitted when building the passwd database. When entries are >= MAXLOGNAME in length, they are correctly stored in passwd, pwd.db and spwd.db but are only correctly retrieved by getpwent*() and getpwuid*(). getpwnam*() truncates to MAXLOGNAME - 1 when reading from a file (breaking at least sh, tcsh and bash) and utilities such as su(1) check, complain and fail if the passed name is >= MAXLOGNAME in length. MFC after: 3 weeks
Diffstat (limited to 'usr.sbin/pwd_mkdb')
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index 3c8ca25..2abbcdf 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -204,7 +204,11 @@ main(int argc, char *argv[])
/* check only if password database is valid */
if (Cflag) {
- for (cnt = 1; scan(fp, &pwd); ++cnt);
+ while (scan(fp, &pwd))
+ if (!is_comment && strlen(pwd.pw_name) >= MAXLOGNAME) {
+ warnx("%s: username too long", pwd.pw_name);
+ exit(1);
+ }
exit(0);
}
OpenPOWER on IntegriCloud