summaryrefslogtreecommitdiffstats
path: root/lib/libarchive
diff options
context:
space:
mode:
authorkientzle <kientzle@FreeBSD.org>2009-12-29 05:50:34 +0000
committerkientzle <kientzle@FreeBSD.org>2009-12-29 05:50:34 +0000
commita587aab420ace76053f95f5fe6ce50aa98c02b5f (patch)
tree71fc5dc01232c481afa75a63f2ededb5cc6bdec1 /lib/libarchive
parentb51f9a79863b7769e108ea91b18ac51666df883c (diff)
downloadFreeBSD-src-a587aab420ace76053f95f5fe6ce50aa98c02b5f.zip
FreeBSD-src-a587aab420ace76053f95f5fe6ce50aa98c02b5f.tar.gz
Be a little more skeptical of dev/ino matches when reading cpio files.
This eliminates some false-positives in the hardlink detection logic.
Diffstat (limited to 'lib/libarchive')
-rw-r--r--lib/libarchive/archive_read_support_format_cpio.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/lib/libarchive/archive_read_support_format_cpio.c b/lib/libarchive/archive_read_support_format_cpio.c
index f16c6cb..7e52fbe 100644
--- a/lib/libarchive/archive_read_support_format_cpio.c
+++ b/lib/libarchive/archive_read_support_format_cpio.c
@@ -92,7 +92,7 @@ struct links_entry {
struct links_entry *previous;
int links;
dev_t dev;
- ino_t ino;
+ int64_t ino;
char *name;
};
@@ -727,51 +727,51 @@ atol16(const char *p, unsigned char_cnt)
static void
record_hardlink(struct cpio *cpio, struct archive_entry *entry)
{
- struct links_entry *le;
+ struct links_entry *le;
dev_t dev;
- ino_t ino;
+ int64_t ino;
if (archive_entry_nlink(entry) <= 1)
return;
dev = archive_entry_dev(entry);
- ino = archive_entry_ino(entry);
-
- /*
- * First look in the list of multiply-linked files. If we've
- * already dumped it, convert this entry to a hard link entry.
- */
- for (le = cpio->links_head; le; le = le->next) {
- if (le->dev == dev && le->ino == ino) {
- archive_entry_copy_hardlink(entry, le->name);
-
- if (--le->links <= 0) {
- if (le->previous != NULL)
- le->previous->next = le->next;
- if (le->next != NULL)
- le->next->previous = le->previous;
- if (cpio->links_head == le)
- cpio->links_head = le->next;
+ ino = archive_entry_ino64(entry);
+
+ /*
+ * First look in the list of multiply-linked files. If we've
+ * already dumped it, convert this entry to a hard link entry.
+ */
+ for (le = cpio->links_head; le; le = le->next) {
+ if (le->dev == dev && le->ino == ino) {
+ archive_entry_copy_hardlink(entry, le->name);
+
+ if (--le->links <= 0) {
+ if (le->previous != NULL)
+ le->previous->next = le->next;
+ if (le->next != NULL)
+ le->next->previous = le->previous;
+ if (cpio->links_head == le)
+ cpio->links_head = le->next;
free(le->name);
- free(le);
- }
+ free(le);
+ }
- return;
- }
- }
+ return;
+ }
+ }
- le = (struct links_entry *)malloc(sizeof(struct links_entry));
+ le = (struct links_entry *)malloc(sizeof(struct links_entry));
if (le == NULL)
__archive_errx(1, "Out of memory adding file to list");
- if (cpio->links_head != NULL)
- cpio->links_head->previous = le;
- le->next = cpio->links_head;
- le->previous = NULL;
- cpio->links_head = le;
- le->dev = dev;
- le->ino = ino;
- le->links = archive_entry_nlink(entry) - 1;
- le->name = strdup(archive_entry_pathname(entry));
+ if (cpio->links_head != NULL)
+ cpio->links_head->previous = le;
+ le->next = cpio->links_head;
+ le->previous = NULL;
+ cpio->links_head = le;
+ le->dev = dev;
+ le->ino = ino;
+ le->links = archive_entry_nlink(entry) - 1;
+ le->name = strdup(archive_entry_pathname(entry));
if (le->name == NULL)
__archive_errx(1, "Out of memory adding file to list");
}
OpenPOWER on IntegriCloud