Subject: bin/3181: wrong output when error occurs on "tar -C"
To: None <gnats-bugs@gnats.netbsd.org>
From: Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de>
List: netbsd-bugs
Date: 02/01/1997 21:15:23
>Number:         3181
>Category:       bin
>Synopsis:       tar prints wrong error-msg when directory for -C doesn't exist
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Feb  1 21:50:05 1997
>Last-Modified:
>Originator:     Hubert Feyrer
>Organization:
Hubert Feyrer <hubert.feyrer@rz.uni-regensburg.de>
>Release:        1.2
>Environment:
	
System: NetBSD miyu 1.2 NetBSD 1.2 (MIYU) #8: Sun Jan 26 20:34:03 MET 1997 feyrer@miyu:/usr/disk1/src12/sys/arch/i386/compile/MIYU i386


>Description:
	When you want to extract an archive to an specific directory
	using the -C switch of tar, and that directory doesn't exist,
	a wrong error message is given due to "%d" instead of "%s" in
	the error message string.

	This bug was found when comparing NetBSD 1.2's tar and
	FreeBSD-current's (as of Feb 1st 97) tar.


>How-To-Repeat:

miyu% tar plvxCf /nonexistantdir /tmp/x.tar
tar: Can't change to directory -138422957 : No such file or directory
etc/
etc/resolv.conf
etc/kerberosIV/
etc/mtree/
...

(surprisingly enough, extraction continues, into the current
directory - not so nice, either; should exit, rather)


>Fix:

diff -crNb /usr/src/gnu/usr.bin/tar/tar.c /usr/homes/feyrer/work/FreeBSD/root/usr.src/tar/tar.c
*** /usr/src/gnu/usr.bin/tar/tar.c	Thu Mar 21 18:35:51 1996
--- /usr/homes/feyrer/work/FreeBSD/root/usr.src/tar/tar.c	Tue Jan  7 15:30:00 1997
***************
*** 1135,1141 ****
    if (nlp->fake)
      {
        if (nlp->change_dir && chdir (nlp->change_dir))
! 	msg_perror ("Can't change to directory %d", nlp->change_dir);
        namelist = 0;
        return 1;
      }
--- 1142,1148 ----
    if (nlp->fake)
      {
        if (nlp->change_dir && chdir (nlp->change_dir))
! 	msg_perror ("Can't change to directory %s", nlp->change_dir);
        namelist = 0;
        return 1;
      }

>Audit-Trail:
>Unformatted: