bug in truncate(1) - all FreeBSD versions

Maxim Konovalov maxim at macomnet.ru
Mon Sep 18 09:51:03 PDT 2006


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


More information about the freebsd-bugs mailing list