diff options
author | kientzle <kientzle@FreeBSD.org> | 2008-06-15 04:31:43 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2008-06-15 04:31:43 +0000 |
commit | a3b4c796ab856513547789a39e5caaf80c471369 (patch) | |
tree | ded4dab291744a435ee52c19594bfd94f4bdb567 /lib/libarchive | |
parent | 33322590b26dad4052a5702bd0b2ef052a40a202 (diff) | |
download | FreeBSD-src-a3b4c796ab856513547789a39e5caaf80c471369.zip FreeBSD-src-a3b4c796ab856513547789a39e5caaf80c471369.tar.gz |
Fix the new generic link resolver in libarchive to never match
dirs as hardlinks. In particular, this fixes some recent ports
build failures.
Thanks to: Kris Kennaway
Diffstat (limited to 'lib/libarchive')
-rw-r--r-- | lib/libarchive/archive_entry_link_resolver.c | 3 | ||||
-rw-r--r-- | lib/libarchive/test/test_link_resolver.c | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/libarchive/archive_entry_link_resolver.c b/lib/libarchive/archive_entry_link_resolver.c index c6e17d4..25b98a8 100644 --- a/lib/libarchive/archive_entry_link_resolver.c +++ b/lib/libarchive/archive_entry_link_resolver.c @@ -181,6 +181,9 @@ archive_entry_linkify(struct archive_entry_linkresolver *res, /* If it has only one link, then we're done. */ if (archive_entry_nlink(*e) == 1) return; + /* Directories never have hardlinks. */ + if (archive_entry_filetype(*e) == AE_IFDIR) + return; switch (res->strategy) { case ARCHIVE_ENTRY_LINKIFY_LIKE_TAR: diff --git a/lib/libarchive/test/test_link_resolver.c b/lib/libarchive/test/test_link_resolver.c index a51e4a4..032c059 100644 --- a/lib/libarchive/test/test_link_resolver.c +++ b/lib/libarchive/test/test_link_resolver.c @@ -68,6 +68,24 @@ static void test_linkify_tar(void) assertEqualInt(0, archive_entry_size(entry)); + /* Dirs should never be matched as hardlinks, regardless. */ + archive_entry_set_pathname(entry, "test3"); + archive_entry_set_nlink(entry, 2); + archive_entry_set_filetype(entry, AE_IFDIR); + archive_entry_set_ino(entry, 3); + archive_entry_set_hardlink(entry, NULL); + archive_entry_linkify(resolver, &entry, &e2); + /* Shouldn't be altered, since it wasn't seen before. */ + assert(e2 == NULL); + assertEqualString("test3", archive_entry_pathname(entry)); + assertEqualString(NULL, archive_entry_hardlink(entry)); + + /* Dir, so it shouldn't get matched. */ + archive_entry_linkify(resolver, &entry, &e2); + assert(e2 == NULL); + assertEqualString("test3", archive_entry_pathname(entry)); + assertEqualString(NULL, archive_entry_hardlink(entry)); + archive_entry_free(entry); archive_entry_linkresolver_free(resolver); } |