NetBSD Problem Report #20154
Received: (qmail 11324 invoked by uid 605); 1 Feb 2003 20:42:20 -0000
Message-Id: <200302012042.h11KgFX14603@glen.takilma.net>
Date: Sat, 1 Feb 2003 12:42:15 -0800 (PST)
From: collver1@attbi.com
Sender: gnats-bugs-owner@netbsd.org
Reply-To: collver1@attbi.com
To: gnats-bugs@gnats.netbsd.org
Subject: useradd fails to check length of username
X-Send-Pr-Version: 3.95
>Number: 20154
>Category: misc
>Synopsis: useradd fails to check length of username
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: agc
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 01 20:43:00 +0000 2003
>Closed-Date: Mon Feb 03 12:22:28 +0000 2003
>Last-Modified: Mon Feb 03 12:22:28 +0000 2003
>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:
From: Christian Biere <christianbiere@gmx.de>
To: collver1@attbi.com
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: misc/20154: useradd fails to check length of username
Date: Sat, 1 Feb 2003 22:33:14 +0100
collver1@attbi.com wrote:
> >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;
Note, that cp must be of type unsigned char* or *cp has to be casted to
unsigned char when calling isalnum(). See isalnum(3) for details. The
same for isdigit() et al. which is also used in user.c.
Christian
From: collver1@attbi.com
To: Christian Biere <christianbiere@gmx.de>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: misc/20154: useradd fails to check length of username
Date: Sat, 1 Feb 2003 14:03:51 -0800
On Sat, Feb 01, 2003 at 10:33:14PM +0100, Christian Biere wrote:
> Note, that cp must be of type unsigned char* or *cp has to be casted to
> unsigned char when calling isalnum(). See isalnum(3) for details. The
> same for isdigit() et al. which is also used in user.c.
As long as we are making notes about the context rather than the issue the
PR addresses, I'd like to point out the following. :)
http://mail-index.netbsd.org/tech-userlevel/2001/11/16/0001.html
and related:
http://mail-index.netbsd.org/netbsd-users/2002/10/15/0011.html
Ben
From: "Alistair G. Crooks" <agc@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: pr/20154 CVS commit: src/usr.sbin/user
Date: Mon, 3 Feb 2003 14:20:47 +0200 (EET)
Module Name: src
Committed By: agc
Date: Mon Feb 3 12:20:47 UTC 2003
Modified Files:
src/usr.sbin/user: user.c
Log Message:
Add a check for the length of the login name given by the user.
Provided by Ben Collver in PR 20154
To generate a diff of this commit:
cvs rdiff -r1.65 -r1.66 src/usr.sbin/user/user.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: open->closed
State-Changed-By: agc
State-Changed-When: Mon Feb 3 04:21:16 PST 2003
State-Changed-Why:
agc added the suggested check from the PR.
Thanks for that one.
Responsible-Changed-From-To: misc-bug-people->agc
Responsible-Changed-By: agc
Responsible-Changed-When: Mon Feb 3 04:21:16 PST 2003
Responsible-Changed-Why:
agc took responsibility for this one
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.