summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libarchive/archive_write_open_file.c11
-rw-r--r--lib/libarchive/archive_write_open_filename.c11
2 files changed, 18 insertions, 4 deletions
diff --git a/lib/libarchive/archive_write_open_file.c b/lib/libarchive/archive_write_open_file.c
index 106420f3ed4f..65cdbb604b05 100644
--- a/lib/libarchive/archive_write_open_file.c
+++ b/lib/libarchive/archive_write_open_file.c
@@ -125,8 +125,15 @@ file_open(struct archive *a, void *client_data)
return (ARCHIVE_FATAL);
}
- a->skip_file_dev = pst->st_dev;
- a->skip_file_ino = pst->st_ino;
+ /*
+ * If the output file is a regular file, don't add it to
+ * itself. If it's a device file, it's okay to add the device
+ * entry to the output archive.
+ */
+ if (S_ISREG(pst->st_mode)) {
+ a->skip_file_dev = pst->st_dev;
+ a->skip_file_ino = pst->st_ino;
+ }
return (ARCHIVE_OK);
}
diff --git a/lib/libarchive/archive_write_open_filename.c b/lib/libarchive/archive_write_open_filename.c
index 106420f3ed4f..65cdbb604b05 100644
--- a/lib/libarchive/archive_write_open_filename.c
+++ b/lib/libarchive/archive_write_open_filename.c
@@ -125,8 +125,15 @@ file_open(struct archive *a, void *client_data)
return (ARCHIVE_FATAL);
}
- a->skip_file_dev = pst->st_dev;
- a->skip_file_ino = pst->st_ino;
+ /*
+ * If the output file is a regular file, don't add it to
+ * itself. If it's a device file, it's okay to add the device
+ * entry to the output archive.
+ */
+ if (S_ISREG(pst->st_mode)) {
+ a->skip_file_dev = pst->st_dev;
+ a->skip_file_ino = pst->st_ino;
+ }
return (ARCHIVE_OK);
}