From owner-freebsd-bugs Tue Jun 27 2:30:15 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 9AA4437BF02 for ; Tue, 27 Jun 2000 02:30:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id CAA12364; Tue, 27 Jun 2000 02:30:13 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Date: Tue, 27 Jun 2000 02:30:13 -0700 (PDT) Message-Id: <200006270930.CAA12364@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Bruce Evans Subject: Re: bin/19514: patch to prevent tail'ing directories Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org The following reply was made to PR bin/19514; it has been noted by GNATS. From: Bruce Evans 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