diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-12-18 10:12:01 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-12-18 10:12:01 +0000 |
commit | 552ab2b4d8558772328f85e1f8295fddc79055b9 (patch) | |
tree | 88b680475b85c2e9953b60564287c37896d46222 /lib/libc/gen/getpwent.c | |
parent | b7df98250359c7126b0f3f08a76ed7158f68774a (diff) |
handle long usernames more carefully
Diffstat (limited to 'lib/libc/gen/getpwent.c')
-rw-r--r-- | lib/libc/gen/getpwent.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c index 854e02acea5..cd3af21eecd 100644 --- a/lib/libc/gen/getpwent.c +++ b/lib/libc/gen/getpwent.c @@ -33,7 +33,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char rcsid[] = "$OpenBSD: getpwent.c,v 1.11 1997/07/23 21:04:06 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: getpwent.c,v 1.12 1997/12/18 10:12:00 deraadt Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/param.h> @@ -697,10 +697,14 @@ pwnam_netgrp: bf[0] = _PW_KEYBYNAME; len = strlen(name); - bcopy(name, bf + 1, MIN(len, UT_NAMESIZE)); - key.data = (u_char *)bf; - key.size = MIN(len, UT_NAMESIZE) + 1; - rval = __hashpw(&key); + if (len > UT_NAMESIZE) + rval = 0; + else { + bcopy(name, bf + 1, MIN(len, UT_NAMESIZE)); + key.data = (u_char *)bf; + key.size = MIN(len, UT_NAMESIZE) + 1; + rval = __hashpw(&key); + } if (!_pw_stayopen) { (void)(_pw_db->close)(_pw_db); |