Subject: bin/22995: pax might not restore timestamps on extraction if -C is specified
To: None <gnats-bugs@gnats.netbsd.org>
From: Sergey Svishchev <svs+pr@grep.ru>
List: netbsd-bugs
Date: 09/28/2003 22:37:13
>Number: 22995
>Category: bin
>Synopsis: pax might not restore timestamps on extraction if -C is specified
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: bin-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Sep 28 18:38:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: "Sergey Svishchev" <svs+pr@grep.ru>
>Release: NetBSD 1.6L
>Organization:
>Environment:
>Description:
extract() calls proc_dir() after doing fchdir() to starting directory, and
relative path(s) taken from -C argument(s) become invalid.
>How-To-Repeat:
#!/bin/sh
set -x
cd /var/tmp
mkdir test-case
cd test-case
mkdir -p root/sub root/dub
touch root/sub/file root/dub/more
tar -cf test-case.tar ./root
tar -tf test-case.tar
rm -r root
mkdir chsub chdub
tar -xf test-case.tar -C /var/tmp/test-case/chsub ./root/sub -C /var/tmp/test-case/chdub ./root/dub
rm -r /var/tmp/test-case
+ cd /var/tmp
+ mkdir test-case
+ cd test-case
+ mkdir -p root/sub root/dub
+ touch root/sub/file root/dub/more
+ tar -cf test-case.tar ./root
+ tar -tf test-case.tar
./root
./root/sub
./root/sub/file
./root/dub
./root/dub/more
+ rm -r root
+ mkdir chsub chdub
+ tar -xf test-case.tar -C /var/tmp/test-case/chsub ./root/sub -C /var/tmp/test-case/chdub ./root/dub
tar: Access/modification time set failed on: ./root/dub (No such file or directory)
tar: Access/modification time set failed on: ./root/sub (No such file or directory)
>Fix:
--- tables.c 2003/08/07 09:05:22 1.21
+++ tables.c 2003/09/28 18:14:04
@@ -1214,14 +1214,15 @@
DIRDATA *dblk;
if ((dblk = malloc(sizeof(*dblk))) == NULL ||
- (dblk->name = strdup(name)) == NULL) {
+ (dblk->name = malloc(MAXPATHLEN)) == NULL) {
tty_warn(1,
"Unable to store mode and times for directory: %s",name);
if (dblk != NULL)
free(dblk);
return;
}
+ realpath(name, dblk->name);
dblk->mode = psb->st_mode & 0xffff;
dblk->mtime = psb->st_mtime;
dblk->atime = psb->st_atime;
>Release-Note:
>Audit-Trail:
>Unformatted: