From owner-freebsd-bugs@FreeBSD.ORG Mon Sep 18 16:51:03 2006 Return-Path: X-Original-To: freebsd-bugs@freebsd.org Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5106016A500 for ; Mon, 18 Sep 2006 16:51:03 +0000 (UTC) (envelope-from maxim@macomnet.ru) Received: from mp2.macomnet.net (mp2.macomnet.net [195.128.64.6]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5BCE843D46 for ; Mon, 18 Sep 2006 16:50:52 +0000 (GMT) (envelope-from maxim@macomnet.ru) Received: from localhost (localhost.int.ru [127.0.0.1] (may be forged)) by mp2.macomnet.net (8.13.7/8.13.3) with ESMTP id k8IGohD4087261; Mon, 18 Sep 2006 20:50:44 +0400 (MSD) (envelope-from maxim@macomnet.ru) Date: Mon, 18 Sep 2006 20:50:43 +0400 (MSD) From: Maxim Konovalov To: Sheldon Hearn In-Reply-To: <200608211221.43718@axl.clue.co.za> Message-ID: <20060918204139.H86925@mp2.macomnet.net> References: <200608211221.43718@axl.clue.co.za> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Cc: freebsd-bugs@freebsd.org, Ighighi Ighighi Subject: Re: bug in truncate(1) - all FreeBSD versions X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Sep 2006 16:51:03 -0000 Hello, On Mon, 21 Aug 2006, 12:21+0200, Sheldon Hearn wrote: > On Monday 21 August 2006 11:55, Ighighi Ighighi wrote: > > I'm working on a portable version of truncate(1) and I noticed a lot > > of "continue" statements in the main while() loop that skip the call > > to close(fd) at the end. The obvious consequence is a file > > descriptor leak... > > > > There's still another bug: parselength() does not need to return > > off_t because its return value is checked in the usual binary (0 vs > > -1) way. > > Thanks for the feedback. I believe that the attached patch addresses > both of the concerns raised. maxim 2006-09-18 16:39:23 UTC FreeBSD src repository Modified files: usr.bin/truncate truncate.c Log: o Don't leak fd on error. o parselength() returns 0 or -1 so int is enough for its return type. Submitted by: Ighighi Ighighi, sheldonh MFC after: 3 weeks Revision Changes Path 1.12 +6 -4 src/usr.bin/truncate/truncate.c -- Maxim Konovalov