From owner-freebsd-bugs Thu Dec 23 12:50: 4 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 1911D14F0D for ; Thu, 23 Dec 1999 12:50:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id MAA18140; Thu, 23 Dec 1999 12:50:01 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from www.mt.net (mail.mt.net [206.127.64.134]) by hub.freebsd.org (Postfix) with ESMTP id A31D61580C for ; Thu, 23 Dec 1999 12:43:00 -0800 (PST) (envelope-from forrestc@imach.com) Received: (from root@localhost) by www.mt.net (8.9.3/8.9.3) id BAA22027; Thu, 23 Dec 1999 01:25:54 -0700 (MST) (envelope-from forrestc@imach.com) Message-Id: <199912230825.BAA22027@www.mt.net> Date: Thu, 23 Dec 1999 01:25:54 -0700 (MST) From: forrestc@imach.com Reply-To: forrestc@imach.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: misc/15658: Fix to edquota.c Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 15658 >Category: misc >Synopsis: edquota misinterprets usernames as uid ranges >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Dec 23 12:50:00 PST 1999 >Closed-Date: >Last-Modified: >Originator: Forrest W. Christian >Release: FreeBSD 3.4-STABLE i386 >Organization: iMach, Ltd. >Environment: Apparently all recent versions of FreeBSD. Verified to exist in latest FreeBSD 3.4-STABLE. >Description: The current version of edquota accepts parameters in the form of either a username or a range of userids. In order to determine if a parameter is a range of uid's, it looks to see if the first digit of the parameter is a number, and if the parameter contains a dash. Thus, usernames such as 2-xhibit are treated as a range of uids. The existing code also does no additional error checking and simply performs an atoi on the start of the parameter and on the string starting immediately following the hyphen. >How-To-Repeat: This problem only occurs when using a prototype user. To excersise the chunk of code with the problem, you can run the following command line: edquota -p root 2-xhibit This results in the result: edquota: ending uid (0) must be >= starting uid (2) when using uid ranges >Fix: Apply the following patch to edquota. This performs additional checks on the parameter before determining that it is, in fact, a uid range. ---START OF PATCH---TRIM HERE--- 149,153c149,152 < if (isdigit(*argv[0]) && < (cp = strchr(*argv, '-')) != NULL) { < *cp++ = '\0'; < startuid = atoi(*argv); < enduid = atoi(cp); --- > if ((startuid=(int)(strtol(argv[0],&cp,10))) && > (*(cp++)=='-') && > (enduid=(int)(strtol(cp,&cp,10))) && > (*(cp++)==0) ) { ---END OF PATCH---TRIM HERE--- >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message