From 82e47474bd24db3f09a55d75603cc5d06dabf845 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Fri, 31 May 2013 12:23:26 -0600 Subject: [PATCH] cherry-pick an upstream commit at Paul Eggert's suggestion --- debian/changelog | 7 +++ debian/patches/link-extraction-fix | 73 ++++++++++++++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 81 insertions(+) create mode 100644 debian/patches/link-extraction-fix diff --git a/debian/changelog b/debian/changelog index ee54081f..9d6a7dc4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +tar (1.26+dfsg-6) unstable; urgency=low + + * cherry-pick upstream commit at Paul Eggert's suggestion to address link + extraction issue, closes: #452365 + + -- Bdale Garbee Fri, 31 May 2013 12:12:35 -0600 + tar (1.26+dfsg-5) unstable; urgency=low [ Wookey ] diff --git a/debian/patches/link-extraction-fix b/debian/patches/link-extraction-fix new file mode 100644 index 00000000..9f70fd79 --- /dev/null +++ b/debian/patches/link-extraction-fix @@ -0,0 +1,73 @@ +Description: link extraction fix + tar (1.26+dfsg-6) unstable; urgency=low + . + * cherry-pick upstream commit at Paul Eggert's suggestion to address link + extraction issue, closes: #452365 +Author: Bdale Garbee +Bug-Debian: http://bugs.debian.org/452365 + +--- tar-1.26+dfsg.orig/src/extract.c ++++ tar-1.26+dfsg/src/extract.c +@@ -110,12 +110,15 @@ struct delayed_link + /* The next delayed link in the list. */ + struct delayed_link *next; + +- /* The device, inode number and ctime of the placeholder. Use +- ctime, not mtime, to make false matches less likely if some +- other process removes the placeholder. */ ++ /* The device, inode number and birthtime of the placeholder. ++ birthtime.tv_nsec is negative if the birthtime is not available. ++ Don't use mtime as this would allow for false matches if some ++ other process removes the placeholder. Don't use ctime as ++ this would cause race conditions and other screwups, e.g., ++ when restoring hard-linked symlinks. */ + dev_t dev; + ino_t ino; +- struct timespec ctime; ++ struct timespec birthtime; + + /* True if the link is symbolic. */ + bool is_symlink; +@@ -268,6 +271,15 @@ set_mode (char const *file_name, + } + } + ++/* Return true if A and B are the same birthtimes. ++ Unavailable birthtimes, which have negative tv_nsec members, ++ all compare equal to each other. */ ++static bool ++same_birthtime (struct timespec a, struct timespec b) ++{ ++ return (a.tv_nsec == b.tv_nsec && (a.tv_nsec < 0 || a.tv_sec == b.tv_sec)); ++} ++ + /* Check time after successfully setting FILE_NAME's time stamp to T. */ + static void + check_time (char const *file_name, struct timespec t) +@@ -1076,7 +1088,7 @@ create_placeholder_file (char *file_name + delayed_link_head = p; + p->dev = st.st_dev; + p->ino = st.st_ino; +- p->ctime = get_stat_ctime (&st); ++ p->birthtime = get_stat_birthtime (&st); + p->is_symlink = is_symlink; + if (is_symlink) + { +@@ -1134,7 +1146,7 @@ extract_link (char *file_name, int typef + if (ds->change_dir == chdir_current + && ds->dev == st1.st_dev + && ds->ino == st1.st_ino +- && timespec_cmp (ds->ctime, get_stat_ctime (&st1)) == 0) ++ && same_birthtime (ds->birthtime, get_stat_birthtime (&st1))) + { + struct string_list *p = xmalloc (offsetof (struct string_list, string) + + strlen (file_name) + 1); +@@ -1500,7 +1512,7 @@ apply_delayed_links (void) + if (fstatat (chdir_fd, source, &st, AT_SYMLINK_NOFOLLOW) == 0 + && st.st_dev == ds->dev + && st.st_ino == ds->ino +- && timespec_cmp (get_stat_ctime (&st), ds->ctime) == 0) ++ && same_birthtime (get_stat_birthtime (&st), ds->birthtime)) + { + /* Unlink the placeholder, then create a hard link if possible, + a symbolic link otherwise. */ diff --git a/debian/patches/series b/debian/patches/series index 15f75237..7d2f126b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -2,3 +2,4 @@ doc-hack.diff longlink-hack.diff listed03-linux-only eglibc-2.16-ftbfs-gnulib-nogets +link-extraction-fix -- 2.30.2