summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2020-06-09 07:06:32 +0200
committerMartin Matuska <martin@matuska.org>2020-06-09 07:11:44 +0200
commitcc2f8b59a90556ac52426727819ba6973525887b (patch)
tree1b5231f7be3ebe1c54d79467046a6433b1fad400
parent4c38de353080d856072cd096acbe7cdbb7799111 (diff)
downloadlibarchive-3.4.tar.gz
Skip hardlinks pointing to itself and issue a warning3.4
Fixes #1381
-rw-r--r--libarchive/archive_write_disk_posix.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/libarchive/archive_write_disk_posix.c b/libarchive/archive_write_disk_posix.c
index 0168d0d4..2f86222c 100644
--- a/libarchive/archive_write_disk_posix.c
+++ b/libarchive/archive_write_disk_posix.c
@@ -546,6 +546,7 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
struct fixup_entry *fe;
+ const char *linkname;
int ret, r;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
@@ -591,6 +592,17 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry)
return (ret);
/*
+ * Check if we have a hardlink that points to itself.
+ */
+ linkname = archive_entry_hardlink(a->entry);
+ if (linkname != NULL && strcmp(a->name, linkname) == 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Skipping hardlink pointing to itself: %s",
+ a->name);
+ return (ARCHIVE_WARN);
+ }
+
+ /*
* Query the umask so we get predictable mode settings.
* This gets done on every call to _write_header in case the
* user edits their umask during the extraction for some