Subject: misc/20154: useradd fails to check length of username
To: None <gnats-bugs@gnats.netbsd.org>
From: None <collver1@attbi.com>
List: netbsd-bugs
Date: 02/01/2003 12:42:15
>Number:         20154
>Category:       misc
>Synopsis:       useradd fails to check length of username
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Feb 01 12:43:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        NetBSD 1.6
>Organization:

>Environment:
System: NetBSD glen 1.6 NetBSD 1.6 (GLEN) #4: Sat Jan 4 17:34:25 PST 2003 root@glen:/usr/src/sys/arch/i386/compile/GLEN i386
Architecture: i386
Machine: i386
>Description:
	useradd can create users that userdel cannot delete.
	this is because useradd does not check the length of the user name, and it saves a username too long for getpwent() to retrieve.

>How-To-Repeat:
	# useradd areallylongusernametotestnetbsd
	useradd: Warning: home directory `/home/areallylongusernametotestnetbsd' doesn't exist, and -m was not specified
	# userdel areallylongusernametotestnetbsd
	userdel: No such user `areallylongusernametotestnetbsd'

>Fix:
--- user.c.orig Sat Feb  1 09:40:50 2003
+++ user.c      Sat Feb  1 09:44:08 2003
@@ -628,6 +628,10 @@
 {
        char    *cp;
 
+       if (strlen(login) > LOGIN_NAME_MAX - 1) {
+               return 0;
+       }
+
        for (cp = login ; *cp ; cp++) {
                if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-') {
                        return 0;
>Release-Note:
>Audit-Trail:
>Unformatted: