From owner-svn-src-all@FreeBSD.ORG Tue Dec 29 05:50:34 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D0020106566B; Tue, 29 Dec 2009 05:50:34 +0000 (UTC) (envelope-from kientzle@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id BC0568FC0A; Tue, 29 Dec 2009 05:50:34 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBT5oYwt012582; Tue, 29 Dec 2009 05:50:34 GMT (envelope-from kientzle@svn.freebsd.org) Received: (from kientzle@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBT5oYU2012580; Tue, 29 Dec 2009 05:50:34 GMT (envelope-from kientzle@svn.freebsd.org) Message-Id: <200912290550.nBT5oYU2012580@svn.freebsd.org> From: Tim Kientzle Date: Tue, 29 Dec 2009 05:50:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r201163 - head/lib/libarchive X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2009 05:50:35 -0000 Author: kientzle Date: Tue Dec 29 05:50:34 2009 New Revision: 201163 URL: http://svn.freebsd.org/changeset/base/201163 Log: Be a little more skeptical of dev/ino matches when reading cpio files. This eliminates some false-positives in the hardlink detection logic. Modified: head/lib/libarchive/archive_read_support_format_cpio.c Modified: head/lib/libarchive/archive_read_support_format_cpio.c ============================================================================== --- head/lib/libarchive/archive_read_support_format_cpio.c Tue Dec 29 05:47:46 2009 (r201162) +++ head/lib/libarchive/archive_read_support_format_cpio.c Tue Dec 29 05:50:34 2009 (r201163) @@ -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); + 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; + /* + * 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"); }