From owner-freebsd-bugs Mon Jun 26 1:40: 4 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 C3EF137BA2C for ; Mon, 26 Jun 2000 01:40:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id BAA88549; Mon, 26 Jun 2000 01:40:00 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from smtp10.atl.mindspring.net (smtp10.atl.mindspring.net [207.69.200.246]) by hub.freebsd.org (Postfix) with ESMTP id 9F69737B644 for ; Mon, 26 Jun 2000 01:39:22 -0700 (PDT) (envelope-from kbyanc@kronos.alcnet.com) Received: from gateway.posi.net (user-33qti6u.dialup.mindspring.com [199.174.200.222]) by smtp10.atl.mindspring.net (8.9.3/8.8.5) with ESMTP id EAA24865 for ; Mon, 26 Jun 2000 04:39:19 -0400 (EDT) Received: (from kbyanc@localhost) by gateway.posi.net (8.9.3/8.9.3) id BAA02636; Mon, 26 Jun 2000 01:39:45 -0700 (PDT) (envelope-from kbyanc) Message-Id: <200006260839.BAA02636@gateway.posi.net> Date: Mon, 26 Jun 2000 01:39:45 -0700 (PDT) From: kbyanc@posi.net Reply-To: kbyanc@posi.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/19514: patch to prevent tail'ing directories Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >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