From owner-svn-src-head@FreeBSD.ORG Thu Nov 15 16:26:43 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 3AF2133C for ; Thu, 15 Nov 2012 16:26:43 +0000 (UTC) (envelope-from lists@eitanadler.com) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9F2238FC17 for ; Thu, 15 Nov 2012 16:26:42 +0000 (UTC) Received: by mail-la0-f54.google.com with SMTP id j13so1715028lah.13 for ; Thu, 15 Nov 2012 08:26:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=eitanadler.com; s=0xdeadbeef; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=k1QC+tqawrBpaU+mvEs7MpFeXqBf3krJc6KjbpYjuE4=; b=TM0MMgKjE8lZb8RqopMXBOAL6DPv60S4kumoNM+E9S8nOFCYt0rQGD2p7TjK9sR0jr LBrAmZAo58b97MvnEWS6FPrGbiSPNWVGaBJlGBwN866zNGaWBKCSZdjib7WEJ40cOT9r O2ULJWTUEH8ZIE6yljk5Ihl2LkndbScSMc6g0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :x-gm-message-state; bh=k1QC+tqawrBpaU+mvEs7MpFeXqBf3krJc6KjbpYjuE4=; b=aLUoZsKWIUGtQdts5TlpOkMphMGQFXBEzZ/xmuHP8jPbbqQxYLCCPm8LrtcjbGvw6+ WPmyKiE7g3aUPznH/1u4uxGi1D6q20yEhn+ZxrJQBwIzMr6oU2Hw30Iyrr+lZv4mNCra p3WcS7Kx9ZF0p53GVQtlbuFPIa/uMbHJRIWk5WV8pmMWfQC76ADDHVnBIE+vbX5lXlch UutdIqEtk5/+sLi8dMAFxDuiswIlODQDIMcgjXeGGioDbswvfTvd7pU5pn3MMthakIIA 1TVVZkgECibqLflhwBP405XsDjJX7SYsyIDGDEXPOkflMNxPXlvyArt9XRU2ubuGT32E ZEsg== Received: by 10.112.100.102 with SMTP id ex6mr809644lbb.130.1352996801168; Thu, 15 Nov 2012 08:26:41 -0800 (PST) MIME-Version: 1.0 Sender: lists@eitanadler.com Received: by 10.112.25.166 with HTTP; Thu, 15 Nov 2012 08:26:10 -0800 (PST) In-Reply-To: <20121115153030.GD73505@kib.kiev.ua> References: <201211151506.qAFF63v0003848@svn.freebsd.org> <20121115153030.GD73505@kib.kiev.ua> From: Eitan Adler Date: Thu, 15 Nov 2012 11:26:10 -0500 X-Google-Sender-Auth: B2o9YISObvKAxMOUiXKRBcKSeys Message-ID: Subject: Re: svn commit: r243076 - head/usr.sbin/chkgrp To: Konstantin Belousov Content-Type: text/plain; charset=UTF-8 X-Gm-Message-State: ALoCoQkMxV2MhT6iYwobM1vaRAah4D7XyySXVrtL1DyUAoIu/qtOKld5hNLcjeMc7cVJyGnsKiEg Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list 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: Thu, 15 Nov 2012 16:26:43 -0000 On 15 November 2012 10:30, Konstantin Belousov wrote: > On Thu, Nov 15, 2012 at 03:06:03PM +0000, Eitan Adler wrote: >> Author: eadler >> Date: Thu Nov 15 15:06:03 2012 >> New Revision: 243076 >> URL: http://svnweb.freebsd.org/changeset/base/243076 >> >> Log: >> Check the range of the gid >> >> 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:00 2012 (r243075) >> +++ head/usr.sbin/chkgrp/chkgrp.c Thu Nov 15 15:06:03 2012 (r243076) >> @@ -30,7 +30,10 @@ >> __FBSDID("$FreeBSD$"); >> >> #include >> +#include >> #include >> +#include >> +#include >> #include >> #include >> #include >> @@ -150,6 +153,18 @@ main(int argc, char *argv[]) >> warnx("%s: line %d: GID is not numeric", gfn, n); >> e++; >> } >> + >> + /* check the range of the group id */ >> + errno = 0; >> + unsigned long groupid = strtoul(f[2], NULL, 10); > And this violates style. > The checks for strtoul failure are not exhaustive. from the strtoul man page: ==== ... In all cases, errno is set to ERANGE. If no conversion could be performed, 0 is returned and the global variable errno is set to EINVAL (the last feature is not por- table across all platforms). === What is missing? Is there a case where strtoul fails but errno == 0 ? -- Eitan Adler Source, Ports, Doc committer Bugmeister, Ports Security teams