summaryrefslogtreecommitdiffstats
path: root/usr.bin/tar
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2006-04-02 07:13:11 +0000
committerkientzle <kientzle@FreeBSD.org>2006-04-02 07:13:11 +0000
commitfa151876bec4b12ec4b1f3c8e129864abcdf0278 (patch)
treeaf6113a31885013bd47066e4ecc198557c651859 /usr.bin/tar
parentaf01e3f8099c15cac3f8392c9e2d7871cfbfd4b8 (diff)
downloadFreeBSD-src-fa151876bec4b12ec4b1f3c8e129864abcdf0278.zip
FreeBSD-src-fa151876bec4b12ec4b1f3c8e129864abcdf0278.tar.gz
If you see a broken symlink, don't try to follow it,
just archive it as a symlink, even if -h was specified. Thanks to: Jin Guojun PR: bin/95175 MFC After: 1 week
Diffstat (limited to 'usr.bin/tar')
-rw-r--r--usr.bin/tar/Makefile2
-rw-r--r--usr.bin/tar/write.c9
2 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile
index e3ccef0..77ace02 100644
--- a/usr.bin/tar/Makefile
+++ b/usr.bin/tar/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PROG= bsdtar
-VERSION= 1.2.51
+VERSION= 1.2.53
SRCS= bsdtar.c getdate.y matching.c read.c tree.c util.c write.c
WARNS?= 5
DPADD= ${LIBARCHIVE} ${LIBBZ2} ${LIBZ}
diff --git a/usr.bin/tar/write.c b/usr.bin/tar/write.c
index 3f08eb0..19ed127 100644
--- a/usr.bin/tar/write.c
+++ b/usr.bin/tar/write.c
@@ -629,15 +629,18 @@ write_hierarchy(struct bsdtar *bsdtar, struct archive *a, const char *path)
*/
switch(symlink_mode) {
case 'H':
- /* 'H': First item (from command line) like 'L'. */
- lst = tree_current_stat(tree);
/* 'H': After the first item, rest like 'P'. */
symlink_mode = 'P';
- break;
+ /* 'H': First item (from command line) like 'L'. */
+ /* FALLTHROUGH */
case 'L':
/* 'L': Do descend through a symlink to dir. */
/* 'L': Archive symlink to file as file. */
lst = tree_current_stat(tree);
+ /* If stat fails, we have a broken symlink;
+ * in that case, archive the link as such. */
+ if (lst == NULL)
+ lst = tree_current_lstat(tree);
break;
default:
/* 'P': Don't descend through a symlink to dir. */
OpenPOWER on IntegriCloud