From owner-svn-src-head@FreeBSD.ORG Fri Nov 16 00:52:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id F18B292A for ; Fri, 16 Nov 2012 00:52:11 +0000 (UTC) (envelope-from postmaster@mailpod.hostingplatform.com) Received: from atl4mhob04.myregisteredsite.com (atl4mhob04.myregisteredsite.com [209.17.115.42]) by mx1.freebsd.org (Postfix) with ESMTP id 84C5A8FC12 for ; Fri, 16 Nov 2012 00:52:11 +0000 (UTC) Received: from mailpod1.hostingplatform.com (mailpod1.networksolutionsemail.com [206.188.198.65]) by atl4mhob04.myregisteredsite.com (8.14.4/8.14.4) with ESMTP id qAG0qBLr013994 for ; Thu, 15 Nov 2012 19:52:11 -0500 Received: (qmail 16438 invoked by uid 0); 16 Nov 2012 00:52:10 -0000 Received: (qmail 2603 invoked by uid 0); 15 Nov 2012 15:51:29 -0000 Received: (qmail 2525 invoked by uid 0); 15 Nov 2012 15:12:46 -0000 Received: from unknown (HELO atl4mhib29.myregisteredsite.com) (209) by 0 with SMTP; 15 Nov 2012 15:12:46 -0000 Received: from mx2.freebsd.org (mx2.freebsd.org [69.147.83.53]) by atl4mhib29.myregisteredsite.com (8.14.4/8.14.4) with ESMTP id qAFF8H7X006506 for ; Thu, 15 Nov 2012 10:08:17 -0500 Received: from hub.freebsd.org (hub.FreeBSD.org [8.8.178.136]) by mx2.freebsd.org (Postfix) with ESMTP id 9D7943B5E65; Thu, 15 Nov 2012 15:08:06 +0000 (UTC) Received: from hub.FreeBSD.org (hub.FreeBSD.org [8.8.178.136]) by hub.freebsd.org (Postfix) with ESMTP id 3631213EE; Thu, 15 Nov 2012 15:08:07 +0000 (UTC) (envelope-from owner-svn-src-all@freebsd.org) Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AC4808B7; Thu, 15 Nov 2012 15:06:24 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 78D768FC17; Thu, 15 Nov 2012 15:06:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qAFF6OtY004168; Thu, 15 Nov 2012 15:06:24 GMT (envelope-from eadler@svn.freebsd.org) Received: (from eadler@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qAFF6OEE004167; Thu, 15 Nov 2012 15:06:24 GMT (envelope-from eadler@svn.freebsd.org) Message-Id: <201211151506.qAFF6OEE004167@svn.freebsd.org> From: Eitan Adler Date: Thu, 15 Nov 2012 15:06:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r243083 - head/usr.sbin/chkgrp X-SVN-Group: head MIME-Version: 1.0 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: owner-svn-src-all@freebsd.org Sender: owner-svn-src-all@freebsd.org X-SpamScore: 0 X-MailHub-Apparently-To: mjm@michaelmeltzer.com X-MailHub-Forwarded: Yes X-BeenThere: svn-src-head@freebsd.org List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Nov 2012 00:52:12 -0000 Author: eadler Date: Thu Nov 15 15:06:24 2012 New Revision: 243083 URL: http://svnweb.freebsd.org/changeset/base/243083 Log: Be declarative about if an error has occured. Fixes overflow on very large group files with lots of errors. This is unlikely to occur in practice. Approved by: cperciva MFC after: 1 week Modified: head/usr.sbin/chkgrp/chkgrp.c Modified: head/usr.sbin/chkgrp/chkgrp.c ============================================================================== --- head/usr.sbin/chkgrp/chkgrp.c Thu Nov 15 15:06:21 2012 (r243082) +++ head/usr.sbin/chkgrp/chkgrp.c Thu Nov 15 15:06:24 2012 (r243083) @@ -81,7 +81,7 @@ main(int argc, char *argv[]) break; if (len > 0 && line[len - 1] != '\n') { warnx("%s: line %d: no newline character", gfn, n); - e++; + e = 1; } while (len && isspace(line[len-1])) len--; @@ -114,14 +114,14 @@ main(int argc, char *argv[]) warnx("%s: line %d: missing field(s)", gfn, n); for ( ; k < 4; k++) f[k] = empty; - e++; + e = 1; } for (cp = f[0] ; *cp ; cp++) { if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' && (cp > f[0] || *cp != '+')) { warnx("%s: line %d: '%c' invalid character", gfn, n, *cp); - e++; + e = 1; } } @@ -129,14 +129,14 @@ main(int argc, char *argv[]) if (!isalnum(*cp) && *cp != '.' && *cp != '_' && *cp != '-' && *cp != ',') { warnx("%s: line %d: '%c' invalid character", gfn, n, *cp); - e++; + e = 1; } } /* check if fourth field ended with a colon */ if (i < len) { warnx("%s: line %d: too many fields", gfn, n); - e++; + e = 1; } /* check that none of the fields contain whitespace */ @@ -144,14 +144,14 @@ main(int argc, char *argv[]) if (strcspn(f[k], " \t") != strlen(f[k])) { warnx("%s: line %d: field %d contains whitespace", gfn, n, k+1); - e++; + e = 1; } } /* check that the GID is numeric */ if (strspn(f[2], "0123456789") != strlen(f[2])) { warnx("%s: line %d: GID is not numeric", gfn, n); - e++; + e = 1; } /* check the range of the group id */ @@ -163,7 +163,7 @@ main(int argc, char *argv[]) else if (groupid > GID_MAX) { warnx("%s: line %d: group id is too large (> %ju)", gfn, n, (uintmax_t)GID_MAX); - e++; + e = 1; } #if 0 _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"