Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 329105 - Tar --keep-old-files symlink extracting endless loop
Summary: Tar --keep-old-files symlink extracting endless loop
Status: RESOLVED DUPLICATE of bug 327641
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Linux bug wranglers
Depends on:
Reported: 2010-07-20 11:51 UTC by Alexandr A. Panko
Modified: 2010-08-12 19:54 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Alexandr A. Panko 2010-07-20 11:51:41 UTC
There is bug in source code of tar application (app-arch/tar-1.23-r2).
It goes in endless loop in attempt to extract already existing symlink if option --keep-old-files set.

Reproducible: Always

Steps to Reproduce:
1. touch file
2. ln -s file file_link
3. tar -cf test.tar file_link
4. tar -xkf test.tar  

Actual Results:  
tar goes in endless loop (or loops till link "file_link" will be deleted).

Expected Results:  
To successfully finish execution and to do not touch symlink.

Here is my patch to fix this error:

diff -ur src.orig/extract.c src/extract.c
--- src.orig/extract.c	2010-01-26 13:28:09.000000000 +0200
+++ src/extract.c	2010-07-20 14:47:24.000000000 +0300
@@ -1018,10 +1018,13 @@
 	  || contains_dot_dot (current_stat_info.link_name)))
     return create_placeholder_file (file_name, true, &interdir_made);
-  while ((status = symlink (current_stat_info.link_name, file_name)))
-    if (!maybe_recoverable (file_name, &interdir_made))
-      break;
+  while ((status = symlink (current_stat_info.link_name, file_name))){
+    switch (maybe_recoverable (file_name, &interdir_made)){
+	case RECOVER_OK: continue;
+	case RECOVER_SKIP: status=0; break;
+    }
+    break;
+  }
   if (status == 0)
     set_stat (file_name, &current_stat_info, NULL, 0, 0, SYMTYPE);
Comment 1 Rafał Mużyło 2010-07-20 13:07:18 UTC

*** This bug has been marked as a duplicate of bug 327641 ***
Comment 2 Alexandr A. Panko 2010-08-12 07:54:41 UTC
Please unmask it for amd64.

I installed tar-1.23-r4 by ebuild directly.
All seems to work properly.

#ls /etc/make.profile -ld
lrwxrwxrwx 1 root root 62 May 16 20:58 /etc/make.profile -> ../usr/portage/profiles/default/linux/amd64/10.0/desktop/gnome

So could you unmask it?
Comment 3 Wormo (RETIRED) gentoo-dev 2010-08-12 19:47:03 UTC
Thanks for reporting your successful testing results for tar-1.23-r4

The tar-1.23-r4 ebuild is already marked "testing" for amd64, but it is less than a month old so we need to wait at least another week before requesting it be stabled. Since it is such a core package, the devs may want to give it even more time to make sure new bugs don't show up from the fix; in the meantime, people who run across this particular problem can add the new tar to /etc/portage/package.keywords

Thus I suggest waiting a week or two and then check to see if there are bugs reported against tar-1.23-r4 -- if not, please feel free to open a new one to request stabling, referring to this endless-loop issue as motivation to mark the recent one stable.

*** This bug has been marked as a duplicate of bug 327641 ***