From: Michihiro NAKAJIMA Date: Sun, 6 Dec 2009 16:00:34 +0000 (-0500) Subject: Do not try finding hardlinked files which are resolved. X-Git-Tag: v2.8.0~112 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c28fa0bcabf3996e0d33a69d18681eed8e6df7ff;p=thirdparty%2Flibarchive.git Do not try finding hardlinked files which are resolved. SVN-Revision: 1707 --- diff --git a/libarchive/archive_read_support_format_xar.c b/libarchive/archive_read_support_format_xar.c index 2fb62a091..f4425fb6e 100644 --- a/libarchive/archive_read_support_format_xar.c +++ b/libarchive/archive_read_support_format_xar.c @@ -596,26 +596,31 @@ read_toc(struct archive_read *a) * Connect hardlinked files. */ for (i = 0; i < xar->file_queue.used; i++) { - struct hdlink *hdlink; + struct hdlink **hdlink; struct xar_file *file; file = xar->file_queue.files[i]; /* Check if 'file' is a target file of the hardlink. */ if (file->link != (unsigned int)-1) continue; - for (hdlink = xar->hdlink_list; hdlink != NULL; - hdlink = hdlink->next) { - if (hdlink->id == file->id) { + for (hdlink = &(xar->hdlink_list); *hdlink != NULL; + hdlink = &((*hdlink)->next)) { + if ((*hdlink)->id == file->id) { + struct hdlink *hltmp; struct xar_file *f2; - int nlink = hdlink->cnt + 1; + int nlink = (*hdlink)->cnt + 1; file->nlink = nlink; - for (f2 = hdlink->files; f2 != NULL; + for (f2 = (*hdlink)->files; f2 != NULL; f2 = f2->hdnext) { f2->nlink = nlink; archive_string_copy( &(f2->hardlink), &(file->pathname)); } + /* Remove resolved files from hdlist_list. */ + hltmp = *hdlink; + *hdlink = hltmp->next; + free(hltmp); break; } }