Date: Mon, 26 Jun 2000 01:39:45 -0700 (PDT) From: kbyanc@posi.net To: FreeBSD-gnats-submit@freebsd.org Subject: bin/19514: patch to prevent tail'ing directories Message-ID: <200006260839.BAA02636@gateway.posi.net>
next in thread | raw e-mail | index | archive | help
>Number: 19514
>Category: bin
>Synopsis: patch to prevent tail'ing directories
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Mon Jun 26 01:40:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Kelly Yancey
>Release: FreeBSD 4.0-STABLE i386
>Organization:
>Environment:
FreeBSD vaio 4.0-STABLE FreeBSD 4.0-STABLE #6: Sun Jun 25 18:32:08 PDT
2000 kbyanc@vaio:/usr/src/sys/compile/VAIO i386
(although tail.c is identical in -current)
>Description:
tail(1) does not prevent the user from doing nonsensical things
like tail'ing directories. Other commands, i.e. more(1) do. This
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.
>How-To-Repeat:
tail .
>Fix:
--- 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);
+ if (sb.st_mode & S_IFLNK)
+ /* This should transparently be resolved and
+ * thus never happen.
+ */
+ errx(1, "%s is a symlink", fname);
+ if (sb.st_mode & S_IFWHT)
+ /* This should never happen. */
+ errx(1, "%s is a whiteout entry", fname);
if (argc > 1) {
(void)printf("%s==> %s <==\n",
first ? "" : "\n", fname);
>Release-Note:
>Audit-Trail:
>Unformatted:
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?200006260839.BAA02636>
