Subject: bin/2483: tar -C dir option doesn't abort if it can't chdir
To: None <gnats-bugs@NetBSD.ORG>
From: None <davide@PIPER.NECTAR.CS.CMU.EDU>
List: netbsd-bugs
Date: 05/29/1996 13:39:18
>Number:         2483
>Category:       bin
>Synopsis:       tar -C dir option doesn't abort if it can't chdir
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 29 13:50:04 1996
>Last-Modified:
>Originator:     David Eckhardt
>Organization:
Carnegie Mellon University
>Release:        1.1
>Environment:
	System: NetBSD piper.nectar.cs.cmu.edu 1.1 NetBSD 1.1 (GENERICOTHER) #1: Wed Mar 6 20:50:20 EST 1996 root@orion.fac.cs.cmu.edu:/usr/src/sys/arch/i386/compile/GENERICOTHER i386

>Description:
	tar's -C dir option (change directory in the middle of processing
	args) doesn't abort the tar if it fails to chdir.  This is bad because
	you can tar the wrong files (and maybe fill up your disk if what
	you get is larger than what you wanted to get).
>How-To-Repeat:
	piper% mkdir /tmp/dir1
	piper% cd /tmp/dir1
	piper% touch foo
	piper% tar cf /tmp/tarfile -C /tmp/nosuchdir .
	tar: Can't chdir to /tmp/nosuchdir : No such file or directory
	piper% tar tvf /tmp/tarfile
	drwxr-xr-x davide/mail       0 May 29 13:14 1996 ./
	-rw-r--r-- davide/mail       0 May 29 13:14 1996 foo

	I should have an empty /tmp/tarfile, certainly not one containing
	/dir1/foo.
>Fix:
	Add a check after the chdir()--if it fails, abort.
	(probably this should filter back to the GNU folks)
>Audit-Trail:
>Unformatted: