From owner-freebsd-bugs Mon Jan 20 14:00:03 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id OAA01410 for bugs-outgoing; Mon, 20 Jan 1997 14:00:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id OAA01387; Mon, 20 Jan 1997 14:00:01 -0800 (PST) Resent-Date: Mon, 20 Jan 1997 14:00:01 -0800 (PST) Resent-Message-Id: <199701202200.OAA01387@freefall.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-bugs Resent-Reply-To: FreeBSD-gnats@freefall.FreeBSD.org, Tor.Egge@idt.ntnu.no Received: from pat.idt.unit.no (0@pat.idt.unit.no [129.241.103.5]) by freefall.freebsd.org (8.8.4/8.8.4) with ESMTP id NAA01114 for ; Mon, 20 Jan 1997 13:55:41 -0800 (PST) Received: from bitbucket.idt.ntnu.no (bitbucket.idt.ntnu.no [129.241.111.175]) by pat.idt.unit.no (8.8.4/8.8.4) with ESMTP id WAA01088 for ; Mon, 20 Jan 1997 22:55:35 +0100 (MET) Received: (from tegge@localhost) by bitbucket.idt.ntnu.no (8.8.4/8.8.3) id WAA14878; Mon, 20 Jan 1997 22:55:34 +0100 (CET) Message-Id: <199701202155.WAA14878@bitbucket.idt.ntnu.no> Date: Mon, 20 Jan 1997 22:55:34 +0100 (CET) From: Tor Egge Reply-To: Tor.Egge@idt.ntnu.no To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: bin/2541: cd (using /bin/sh) may leave you in the wrong directory Sender: owner-bugs@freebsd.org X-Loop: FreeBSD.org Precedence: bulk >Number: 2541 >Category: bin >Synopsis: cd (using /bin/sh) may leave you in the wrong directory >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jan 20 14:00:00 PST 1997 >Last-Modified: >Originator: Tor Egge >Organization: Norwegian University of Science and Technology, Trondheim, Norway >Release: FreeBSD 3.0-CURRENT i386 >Environment: FreeBSD ikke.idt.unit.no 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Mon Jan 20 21:59:08 MET 1997 root@ikke.idt.unit.no:/usr/src/sys-UP/compile/TEGGE i386 >Description: cd (using /bin/sh) may leave you in the wrong directory. >How-To-Repeat: Run the following shell script: --- #!/bin/sh cd /tmp rm -rf /tmp/good /tmp/bad mkdir good mkdir good/some mkdir good/etc echo "Test OK" > good/etc/FILE mkdir bad mkdir bad/etc echo "Test failed" > bad/etc/FILE ln -s ../good/some bad/some cd /tmp/bad/some/../etc cat FILE /bin/pwd cd .. /bin/pwd cd /tmp rm -rf /tmp/good /tmp/bad --- >Fix: Don't blindly eliminate `..' in the target directory name by also eliminating the previous component. If the previous component was a symbolic link, the elimination might be bogus. >Audit-Trail: >Unformatted: