Date: Mon, 18 Sep 2006 20:50:43 +0400 (MSD) From: Maxim Konovalov <maxim@macomnet.ru> To: Sheldon Hearn <sheldonh@clue.co.za> Cc: freebsd-bugs@freebsd.org, Ighighi Ighighi <ighighi@gmail.com> Subject: Re: bug in truncate(1) - all FreeBSD versions Message-ID: <20060918204139.H86925@mp2.macomnet.net> In-Reply-To: <200608211221.43718@axl.clue.co.za> References: <de5dfb5a0608210255s34ce786fo97b502caa37b6f37@mail.gmail.com> <200608211221.43718@axl.clue.co.za>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20060918204139.H86925>
