Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 27 Jun 2000 02:30:13 -0700 (PDT)
From:      Bruce Evans <bde@zeta.org.au>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/19514: patch to prevent tail'ing directories
Message-ID:  <200006270930.CAA12364@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

The following reply was made to PR bin/19514; it has been noted by GNATS.

From: Bruce Evans <bde@zeta.org.au>
To: kbyanc@posi.net
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/19514: patch to prevent tail'ing directories
Date: Tue, 27 Jun 2000 19:22:55 +1000 (EST)

 On Mon, 26 Jun 2000 kbyanc@posi.net wrote:
 
 > >Description:
 > 
 > 	tail(1) does not prevent the user from doing nonsensical things
 > 	like tail'ing directories.
 
 It is a feature of Unix utilities that they do what they are told to do.
 
 >	Other commands, i.e. more(1) do. This
 
 This is a misfeature of more(1) :-).
 
 POSIX.2 (in the old draft that I have) specifically requires "tail -c"
 to accept arbitrary data.  tail(1) without -c is only required to handle
 text files.  head(1) is only required to handle text files.  cat(1) is
 required to handle all types of files.
 
 > 	patch alerts the user when they try to tail a directory. In
 > 	addition, it also adds checks for reading symlink contents and
 > 	whiteout entries, however I can't imagine how either of these
 > 	scenarios would occur.
 
 At least the symlink case can't happen, so don't obfuscate the code
 checking for it.
 
 > --- usr.bin/tail/tail.c.orig	Mon Jun 26 01:30:01 2000
 > +++ usr.bin/tail/tail.c	Mon Jun 26 01:38:38 2000
 > @@ -171,6 +171,16 @@
 >  				ierr();
 >  				continue;
 >  			}
 > +			if (sb.st_mode & S_IFDIR)
 > +				errx(1, "%s is a directory", fname);
 
 Exiting for a non-error is a bug.  The current tail(1) doesn't even exit
 for errors on individual files.
 
 Bruce
 
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006270930.CAA12364>