From owner-freebsd-current@FreeBSD.ORG Thu Aug 25 13:08:45 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0F66C16A41F for ; Thu, 25 Aug 2005 13:08:45 +0000 (GMT) (envelope-from nkalev@gmail.com) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.195]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8C1CE43D48 for ; Thu, 25 Aug 2005 13:08:44 +0000 (GMT) (envelope-from nkalev@gmail.com) Received: by rproxy.gmail.com with SMTP id i8so350563rne for ; Thu, 25 Aug 2005 06:08:43 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:x-accept-language:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding; b=h6Po8CXmEfpXy/MENHiQsBOepbNoxuIX3jWgm9bD+JbKiMNe0lWcRTv3UzlLdKivp60JfL5EI+oAIPvzvPAAfcj1FQXxZOBaQIzsrK8tktvULUpXIWbgjNLr1U+Gq0RjWvGdHJ1PrnD/gk9kvYb2lXv3vUeUxF8iqX14TAaprB0= Received: by 10.38.101.25 with SMTP id y25mr1059947rnb; Thu, 25 Aug 2005 06:08:43 -0700 (PDT) Received: from ?172.16.101.106? ( [212.36.7.117]) by mx.gmail.com with ESMTP id m36sm1353958rnd.2005.08.25.06.08.42; Thu, 25 Aug 2005 06:08:43 -0700 (PDT) Message-ID: <430DC47C.9090908@gmail.com> Date: Thu, 25 Aug 2005 16:15:40 +0300 From: Nikolay Kalev User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050722) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Fredrik Lindberg , freebsd-current@freebsd.org References: <430C36BD.1020808@gmail.com> <20050824222516.GA1106@wantadilla.lemis.com> <430D665B.9030108@gmail.com> <430D7853.8070407@freebsd.org> <430DAE4D.60009@shapeshifter.se> In-Reply-To: <430DAE4D.60009@shapeshifter.se> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Re: Coredump in chkgrp (was Re: unknown coredump !) X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Aug 2005 13:08:45 -0000 Fredrik Lindberg wrote: > Colin Percival wrote: > >> [Bug report CCed to author of bug] >> >> Nikolay Kalev wrote: >> >>> chkgrp: /etc/group: line 30: missing field(s) >>> Segmentation fault (core dumped) >>> Exit 3 >>> >>> so i found the problem in my group file there was a bugy line that i >>> added ... i;m not sure if this is normal to coredump when the syntax in >>> /etc/group is mistaken ??? >>> >>> the line was : "user:1001:" and it has to be "user:*:1001:" >> >> >> >> This bug was added in revision 1.9 of src/usr.sbin/chkgrp/chkgrp.c. If >> a line of the group file has the wrong number of fields, the pointers >> f[0], f[1], f[2], and f[3] might point at deadc0de; prior to this >> revision, >> the number of fields was checked first and processing halted if it was >> wrong. >> >> I'm busy for the next few days, but if this is still unfixed on >> Monday I'll >> take care of it. >> >> Colin Percival > > > Here is a patch that should fix this. > > Fredrik Lindberg > >------------------------------------------------------------------------ > >Index: chkgrp.c >=================================================================== >RCS file: /home/ncvs/src/usr.sbin/chkgrp/chkgrp.c,v >retrieving revision 1.10 >diff -u -r1.10 chkgrp.c >--- chkgrp.c 4 Aug 2005 12:44:36 -0000 1.10 >+++ chkgrp.c 25 Aug 2005 10:50:25 -0000 >@@ -133,18 +133,20 @@ > } > > /* check that none of the fields contain whitespace */ >- for (k = 0; k < 4; k++) { >- if (strcspn(f[k], " \t") != strlen(f[k])) { >+ for (i = 0; i < k; i++) { >+ if (strcspn(f[i], " \t") != strlen(f[i])) { > warnx("%s: line %d: field %d contains whitespace", >- gfn, n, k+1); >+ gfn, n, i+1); > e++; > } > } > > /* 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++; >+ if (k > 2) { >+ if (strspn(f[2], "0123456789") != strlen(f[2])) { >+ warnx("%s: line %d: GID is not numeric", gfn, n); >+ e++; >+ } > } > > #if 0 > > Ok thanks for the patch it works ok now :-) no coredumps !