Subject: bin/35432: tar: x and c options at same time should produce an error
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <phil@cs.wwu.edu>
List: netbsd-bugs
Date: 01/16/2007 16:35:00
>Number:         35432
>Category:       bin
>Synopsis:       tar: x and c options at same time should produce an error
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jan 16 16:35:00 +0000 2007
>Originator:     Phil Nelson
>Release:        NetBSD 4.99.3
>Organization:
	Western Washington University
>Environment:
System: NetBSD cutt.pn.fdns.net 4.99.3 NetBSD 4.99.3 (CUTT) #3: Mon Oct 30 15:25:49 PST 2006 phil@doe:/home/phil/netbsd/src/sys/arch/i386/compile/CUTT i386
Architecture: i386
Machine: i386
>Description:
	When tar is run with both the x and c options, it should report
	an error that one can not both extract and create the tar file
	at the same time.   Currently, that last option is the option
        in force.  So the invocation "tar xc ..." is the same as
	"tar c ..." where "tar cx ..." is the same as "tar x ..."

>How-To-Repeat:
	1) Create a tar file like "tar czf junk.tgz junk" where junk
	has some files in the directory junk.

	2) Run "tar xzcf junk.tgz badpath"  and watch tar overwrite
	junk.tgz with garbage and blow away the previous contents of
	junk.tgz.

	(Yes, I lost a 30G tar file due to this problem.)

>Fix:
	I haven't looked at the option processing code yet, but I 
	plan on looking at it.  This is filed in case someone much
	more famalier with tar can do this fix much more quickly than
	I can.