Received: (qmail 18535 invoked by uid 605); 1 Feb 2003 23:37:40 -0000
Message-Id: <20030202003737.4c95c303.christianbiere@gmx.de>
Date: Sun, 2 Feb 2003 00:37:37 +0100
From: Christian Biere <christianbiere@gmx.de>
Sender: gnats-bugs-owner@netbsd.org
Reply-To: gnats-bugs@gnats.netbsd.org, christianbiere@gmx.de
To: gnats-bugs@gnats.netbsd.org
Subject: Wrong usage of is{digit,alnum,space} in user
>Number: 20156
>Category: bin
>Synopsis: Wrong usage of is{digit,alnum,space} in user
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: jrf
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Feb 01 23:38:01 +0000 2003
>Closed-Date: Fri Mar 14 16:57:50 +0000 2003
>Last-Modified: Fri Mar 14 16:58:00 +0000 2003
>Originator: Christian Biere
>Release: NetBSD 1.6K
>Organization:
>Environment:
>Description:
While reading PR misc/20154 I've noticed the following:
In src/usr.sbin/user/user.c isalnum(), isdigit() and isspace() are used
with a char as parameter. On platforms with char being signed char by
default this means calling those function with invalid arguments and
results are undefined.
Note, that those functions also respect the locale settings which might
not have been considered here. I haven't verified whether this is of any
concern.
>How-To-Repeat:
>Fix:
--Multipart_Sun__2_Feb_2003_00:37:37_+0100_082bda00
Content-Type: text/plain;
name="user.c.udif"
Content-Disposition: attachment;
filename="user.c.udif"
Content-Transfer-Encoding: 7bit
Index: user.c
===================================================================
RCS file: /cvsroot/src/usr.sbin/user/user.c,v
retrieving revision 1.65
diff -u -r1.65 user.c
--- user.c 2002/11/08 11:53:20 1.65
+++ user.c 2003/02/01 23:20:56
@@ -354,7 +354,7 @@
is_number(char *s)
{
for ( ; *s ; s++) {
- if (!isdigit(*s)) {
+ if (!isdigit((unsigned char) *s)) {
return 0;
}
}
@@ -636,7 +636,7 @@
static int
valid_login(char *login_name)
{
- char *cp;
+ unsigned char *cp;
for (cp = login_name ; *cp ; cp++) {
if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-') {
@@ -650,7 +650,7 @@
static int
valid_group(char *group)
{
- char *cp;
+ unsigned char *cp;
for (cp = group ; *cp ; cp++) {
if (!isalnum(*cp)) {
@@ -765,8 +765,8 @@
size_t lineno;
size_t len;
FILE *fp;
- char *cp;
- char *s;
+ unsigned char *cp;
+ unsigned char *s;
memsave(&up->u_primgrp, DEF_GROUP, strlen(DEF_GROUP));
memsave(&up->u_basedir, DEF_BASEDIR, strlen(DEF_BASEDIR));
@@ -931,7 +931,7 @@
*tp = mktime(&tm);
} else if (strptime(s, "%B %d %Y", &tm) != NULL) {
*tp = mktime(&tm);
- } else if (isdigit(s[0]) != NULL) {
+ } else if (isdigit((unsigned char) s[0]) != NULL) {
*tp = atoi(s);
} else {
return 0;
--Multipart_Sun__2_Feb_2003_00:37:37_+0100_082bda00--
>Release-Note:
>Audit-Trail:
From: gnats-admin@netbsd.org
To: gnats-bugs@gnats.netbsd.org, christianbiere@gmx.de
Cc:
Subject: Re: bin/20156: Wrong usage of is{digit,alnum,space} in user
Date: 1 Feb 2003 23:38:01 -0000
Thank you very much for your problem report.
It has the internal identification `bin/20156'.
The individual assigned to look at your
report is: bin-bug-people.
>Category: bin
>Responsible: bin-bug-people
>Synopsis: Wrong usage of is{digit,alnum,space} in user
>Arrival-Date: Sat Feb 01 15:38:01 PST 2003
Responsible-Changed-From-To: bin-bug-people->jrf
Responsible-Changed-By: jrf
Responsible-Changed-When: Thu Mar 13 15:40:05 PST 2003
Responsible-Changed-Why:
This one doesn't look too hard. I will test it out and ask a senior developer
to review it if it looks okay.
From: "Jason R. Fink" <jrf@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:
Subject: pr/20156 CVS commit: src/usr.sbin/user
Date: Fri, 14 Mar 2003 18:56:41 +0200 (EET)
Module Name: src
Committed By: jrf
Date: Fri Mar 14 16:56:40 UTC 2003
Modified Files:
src/usr.sbin/user: user.c
Log Message:
This addresses PR 20156. isalnum(), isdigit() and isspace() are used with
char as a parameter. On platforms with char signed by default, those are wrong.
Thanks to Christian Biere christianbiere@gmx.de for the patch he supplied.
I tested the patch and agc approved it for commit.
To generate a diff of this commit:
cvs rdiff -r1.66 -r1.67 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: jrf
State-Changed-When: Fri Mar 14 08:57:00 PST 2003
State-Changed-Why:
Tested the patch and commited after approval from agc.
From: jrf@netbsd.org
To: gnats-bugs@gnats.netbsd.org, christianbiere@gmx.de, jrf@netbsd.org,
jrf@netbsd.org
Cc:
Subject: Re: bin/20156
Date: 14 Mar 2003 16:57:45 -0000
Synopsis: Wrong usage of is{digit,alnum,space} in user
State-Changed-From-To: open->closed
State-Changed-By: jrf
State-Changed-When: Fri Mar 14 08:57:00 PST 2003
State-Changed-Why:
Tested the patch and commited after approval from agc.
>Unformatted:
This is a multi-part message in MIME format.
--Multipart_Sun__2_Feb_2003_00:37:37_+0100_082bda00
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
|
|